javascript - 如何理解angular的这段代码?
问题描述
define([’APP’],function(APP){’use strict’;APP.controller(’CuisineController’, [’title’,’$http’,’$scope’,’$state’,’$stateParams’,function( title , $http , $scope , $state , $stateParams ) { $scope.UrlGet = $$.getUrlParams();$scope.Load = {initValue : function(){ },Jump: function(index) {$state.go(’cuisineDetails’,{’index’:index}); }, bussiness: function() { }, init : function(){$$(’.ModalBlank.ModalBlankVisibleIn’).tap().click();window.setTitle(title);//$scope.Load.setUseTime();$scope.Load.initValue();//$scope.Load.bussiness();window.initDeviceReady($scope.Load.bussiness); }};$scope.Load.init(); }]);}); 维护别人的angular 代码 用了require 不太明白这段代码的开头的部分,请大神指点指点 尤其是define([’APP’],function(APP){’use strict’;APP.controller(’CuisineController’, [’title’,’$http’,’$scope’,’$state’,’$stateParams’,function( title , $http , $scope , $state , $stateParams ) {//获取url参数$scope.UrlGet = $$.getUrlParams();//声明[’title’,’$http’,’$scope’,’$state’,’$stateParams’,function( title , $http , $scope , $state , $stateParams ) { $scope.UrlGet = $$.getUrlParams();
问题解答
回答1:既然你已经说了require,那代码就很好明白了。define 是require里的,定义一个模块。[’app’] 是一个依赖数组,直白点说就是,这个模块依赖了一个app的模块,把这个app引入进来,重命名为 APP。这个APP提供了controller这个方法,由此可知,这个APP应该就是一个 angular module
相关文章:
1. jupyter-notebook - Mac下启动jupyter notebook后没有Python的选项?2. Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?3. css3 - 这个效果用 CSS 可以实现吗?border-image4. android - webview 自定义加载进度条5. 输入地址报以下截图错误,怎么办?6. javascript - vue更改当前节点元素7. vue.js - vue 打包后 nginx 服务端API请求跨域问题无法解决。8. mac连接阿里云docker集群,已经卡了2天了,求问?9. angular.js - angular post的Content-Type被设置,导致不能上传图片,求助!!10. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?

网公网安备