2016-11-07 3 views
0

안녕하세요 각도 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 }; }); 

에서 여러 지시를 시도하고 난 단 하나의

<h1> hello I am external on file </h1> 
이 main.html

<body ng-controller= "myController as myCtrl"> 
    <h1>Hello Plunker!</h1> 
    <my-Directive1></my-Directive1> 
    <my-Directive2></my-Directive2> 
    </body> 

및 directiveTry.html을 만들었습니다

텍스트를 표시 할 수 없습니다. 어디에서 오해합니까? 답변

덕분에

+1

restict : 매개 변수가 없습니다. 그것은'restrict'이고 A는 속성을 나타냅니다. E를 찾고 있습니다. 또한 templateUrl 값을 따옴표로 묶어야합니다. 문자열입니다 –

+0

확인 완료되었지만 지시문을 표시하지 않습니다 – nowaySync

+0

구문은

답변

0
app.directive('myDirective1', function() { 
    return { 
    restrict: 'AE', 
    replace: 'true', 
    template: '<h3>Hello World!!</h3>' 
    }; 
}); 

사용과 같은 :

<my-directive1></my-directive1> 
<div my-directive1></div> 

는 간단한 기사를 읽거나 유튜브가 https://www.sitepoint.com/practical-guide-angularjs-directives/

+0

으로 변경된 사항은 없습니다. 이제 메시지를 표시해야합니다. 외부 HTML – nowaySync

+0

Google에 문의 http://techfunda.com/howto/482/custom-directive-with-templateurl –

0

문제가

해결 '방법 각도에서 간단한 지시를 만드는'시청

나는 "r"을 잊어 버렸습니다. 제한의 : (((((

+0

예 ... 내 댓글을보세요. –