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. python - 如何解决程序运行太久之后被操作系统暂停的情况?2. html5 - 为什么浏览器可以显示HTML文档中未被定义的标签?3. javascript - 图片能在网站显示,但控制台仍旧报错403 (Forbidden)4. PhpStudy8.0 CPU过高5. mysql 能不能创建一个 有列级函数 的联合视图?6. python - pig latin问题 总是出现list/string index out of range7. 闯关的第二个问题的答案是错的吧?8. 为什么HTML5规范中会包含一些和html无关的东西?如本地存储等。9. javascript - sublime怎么支持webp的浏览?10. 安装mysql,完成时提示的是用户名root,在终端查看版本时显示的不是root,请问这怎么解决

网公网安备