我一直在关注代码学校的Angular教程,我的应用程序正常工作,直到添加这个自定义指令:
// Breaks here
app.directive('reviewForm', function() {
return {
restrict: 'E',
templateUrl: 'partials/review-form.html',
replace: true,
controller: function() {
this.showForm: false;
},
controllerAs: 'reviewFormCtrl',
}
})
这是我通过console.log收到的错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled
the module name or forgot to load it. If registering a module
ensure that you specify the dependencies as the second argument.
答案 0 :(得分:0)
我认为这是拼写错误,您的模块名称是myApp,并且在您的代码中写道:
app.directive('reviewForm', function() {......
它应该是myApp.directive,如下所示:
myApp.directive('reviewForm', function() {
return {
restrict: 'E',
templateUrl: 'partials/review-form.html',
replace: true,
controller: function() {
this.showForm: false;
},
controllerAs: 'reviewFormCtrl',
}
})
如果不起作用,请检查模块名称的拼写。