AngularJS$parse TypeError:对象不是函数
我已经将我的应用程序剥离到了最底层,但在使用$parse:TypeError:object不是函数时,我一直遇到这个错误 怎么了?我错过了什么 在这种情况下似乎效果很好:AngularJS$parse TypeError:对象不是函数,angularjs,Angularjs,我已经将我的应用程序剥离到了最底层,但在使用$parse:TypeError:object不是函数时,我一直遇到这个错误 怎么了?我错过了什么 在这种情况下似乎效果很好: 解析可能与其他模块冲突吗 更奇怪的是,它确实改变了$scope.modal.on的值!即使它似乎在手之前就死了 /* Controllers */ //var MyApp = angular.module('MyApp', ['ngSanitize', 'ui.bootstrap', 'ui.sortable']); var
解析可能与其他模块冲突吗 更奇怪的是,它确实改变了$scope.modal.on的值!即使它似乎在手之前就死了
/* Controllers */
//var MyApp = angular.module('MyApp', ['ngSanitize', 'ui.bootstrap', 'ui.sortable']);
var MyApp = angular.module('MyApp', ['ngSanitize', 'ui.bootstrap']);
MyApp.controller('MyController', ['$scope', '$http', '$modal', '$parse', function($scope, $http, $parse, $modal, $log) {
$scope.modal = {
open : false,
tplfile : null,
toggle : function(){
this.open = !this.open;
if(this.open) angular.element('body').addClass('modal-open');
else angular.element('body').removeClass('modal-open');
}
};
var modal = $parse('modal.open');
modal.assign($scope, true);
}]);
您以错误的顺序传递了依赖项。函数的依赖项必须与数组中的顺序完全匹配
MyApp.controller('MyController',
['$scope', '$http', '$modal', '$parse', function
($scope, $http, $parse, $modal, $log) {
如果在控制器声明中交换$parse
和$modal
,则错误将消失。此外,您还缺少$log
,如果您尝试使用该依赖项,也会出现错误
['$scope', '$http', '$modal', '$parse', function($scope, $http, $parse, $modal,
$parse
和$modal
是互换的
请更正订单,它将正常工作:)
应该是
MyApp.controller('MyController', ['$scope', '$http', '$modal', '$parse', '$log', function($scope, $http, $modal, $parse, $log) {
成功了,这是命令。你赢了大约30秒;)你完全正确,这很有效。但克莱斯以30秒的优势击败了你谢谢