我是angularJS的新手,並試圖讓下面的簡單示例工作。但是當我跑它,我得到了一個空白的屏幕,而不是「你好世界」。幫助將不勝感激。謝謝。使用angularJS .component()但沒有值
角comp.js:
angular.module('myApp').component('greetUser', {
template: 'Hello, {{$ctrl.user}}!',
controller: function GreetUserController() {
this.user = 'world';
}
});
的index.html:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="ISO-8859-1">
<title>AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"> </script>
<script src="js/angularcomp.js"></script>
</head>
<body>
<greet-user></greet-user>
</body>
</html>
更新:我發現這個問題,版本1.4.5不支持組件。我現在使用1.6.1,它的工作原理!
我工作的這個..等一下 – thiagoh
你可能是指'angular.module( '對myApp',[])',而不是'angular.module('對myApp 「)'。 –