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. java - freemarker如何实现这种贼简单的效果2. css - autoprefixer没有添加web-kit前缀3. windows-7 - Win7中Vmware Workstatoin与Xampp中Apache服务器端口冲突?4. css3 - 没明白盒子的height随width的变化这段css是怎样实现的?5. android-studio - android app微信登录一定要申请了登录权限才能测试?6. javascript - 有什么兼容性比较好的办法来判断浏览器窗口的类型?7. javascript - JS 里面的 delete object.key 到底删除了什么?8. javascript - 为什么输入框什么都没输取到的值却是undefined??9. mysql新建字段时 timestamp NOT NULL DEFAULT ’0000-00-00 00:00:00’ 报错10. java - com.android.internal.R.attr.dialogTheme 这个dialogTheme的内容再哪里查看?

网公网安备