javascript - 如何理解angular的这段代码?
阿神
阿神 2017-06-05 11:10:14
[AngularJS讨论组]

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号