嘿,我想知道有人可以幫助我,告訴我爲什麼我的指令不在Webstorm 9.0中運行。爲什麼它沒有添加我的指令?我認爲這將是非常直接的,但它似乎並沒有注入它。Simpledirective不注射。
enter code here
http://plnkr.co/edit/fKKS1TINMHT4yJF4c9Ol?p=preview
嘿,我想知道有人可以幫助我,告訴我爲什麼我的指令不在Webstorm 9.0中運行。爲什麼它沒有添加我的指令?我認爲這將是非常直接的,但它似乎並沒有注入它。Simpledirective不注射。
enter code here
http://plnkr.co/edit/fKKS1TINMHT4yJF4c9Ol?p=preview
這裏給出的模塊名作爲docsSimpleDirective
是plunker 主演關閉您還沒有在NG-應用這就是定義你的名字爲什麼你的應用是不是工作 和腳本文件的順序不同。
http://plnkr.co/edit/2SthQC5fADsi1rdEhq3C?p=preview
var app = angular.module('docsSimpleDirective', []);
app.controller('Controller', function($scope) {
console.log('Hi');
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
})
.directive('myCustomer', function() {
return {
template: 'Name: {{customer.name}} Address: {{customer.address}}'
};
});
你的HTML
<!DOCTYPE html>
<html ng-app="docsSimpleDirective">
<head>
<link rel="stylesheet" href="style.css">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<h1>Hello Plunker!</h1>
<div ng-controller="Controller">
<div my-customer/>
</div>
</body>
</html>
希望它可以幫助
請更改angular.module('docsSimpleDirective', ['index.html'])
到angular.module('docsSimpleDirective', [])
。 index.html
不是依賴項。我們正在將js
文件鏈接到html
文件。而不是相反。
另外,請更改<html ng-app>
到<html ng-app='docsSimpleDirective'>
因爲我們已經在angular.module('docsSimpleDirective', [])
做,但仍然沒有工作..... –
請參閱本plunker。 http://plnkr.co/edit/m7XS228hn04MREj5qDg0?p=preview –
所以cdn不工作?沒有機會你有一個1.5的鏈接,因爲我從那裏得到一個,並沒有工作 https://cdnjs.com/libraries/angular.js/1.5.0 感謝您的幫助 –
非常感謝。我希望我能接受這兩個答案。 –