0
我收到此錯誤 - 錯誤:$控制器:ctrlreg具有此名稱的控制器未註冊。我所有的腳本都被加載,並且我將它們全部添加到index.html中。未在XAMPP Web服務上註冊的角度控制器
我的控制器:
(function() {
angular.module("nsoftModule").controller("nsoftController", ["nsoftService", function(nsoftService) {
var self = this;
self.service = nsoftService;
}])
})();
我的指令:
(function() {
var weatherMod = angular.module("nsoftModule", []);
weatherMod.directive("nsoftDirective", function() {
return {
templateUrl: "Template/weatherTemplate.html",
controller: "nsoftController as nsoftCtrl"
}
});
})();
我的服務:
(function() {
var weatherMod = angular.module("nsoftModule", []);
weatherMod.service("nsoftService", ["http", function(http) {
var service = this;
}]);
})();
我的模塊:
(function() {
var weatherMod = angular.module("nsoftModule", []);
})();
我的模板:
<div class="container">
<div ng-controller="nsoftController">
<p>Name : <input type="text" ng-model="name"></p>
<h1>Hello {{name}}</h1>
</div>
</div>
我app.js:
(function() {
angular.module("nsoftApp", ["nsoftModule"]);
})();
而且我的index.html:
非常感謝您的回答Sachila,但我仍然得到同樣的錯誤甚至是你的改進... –
檢查此。我會更新答案https://plnkr.co/edit/9d64fOb9QhNgCeKl90VY?p=preview –
比你非常,它的作品,真棒! –