你好,我有嘗試的角度JS角JS多個指令
var app = angular.module("myApp", []);
app.controller("myController", function($scope){ });
app.directive("myDirective1", function(){ return {
template: "<h1> hello this is directive with template </h1>" }; });
app.directive("myDirective2", function(){ return{
restict: 'A',
templateUrl: /directiveTry.html }; });
多個指令,我創造了這個main.html中
<body ng-controller= "myController as myCtrl">
<h1>Hello Plunker!</h1>
<my-Directive1></my-Directive1>
<my-Directive2></my-Directive2>
</body>
和directiveTry.html只有一個
<h1> hello I am external on file </h1>
我無法顯示文本,我的mystake在哪裏?
感謝答案
restict:參數不存在。它是「限制」,A代表屬性。您正在尋找E.另外,您應該在引號之間放置templateUrl值。這是一個字符串 –
確定完成,但現在不顯示我的指令2 – nowaySync
的語法應該是'<我的指令性...' –