簡體   English   中英

如何使用指令在Angular中加載外部模板?

[英]How to use directive to load an external template in Angular?

如何使用指令在Angular中加載外部模板?

角,

app.directive('helloWorld', function() {
    return {
        restrict: 'AE',
        replace: true,

        //templateUrl points to an external html template.
        emplateUrl: 'fixture/main.html'
    };
});

HTML,

夾具/ m​​ain.html中,

<div ng-controller="SimpleController">{{sayHello()}}</div>

沒有加載任何內容。 知道我錯過了什么嗎?

用這個

app.directive('helloWorld', function() {
    return {
        restrict: 'AE',
        replace: true,

        //templateUrl points to an external html template.
        templateUrl: 'fixture/main.html'
    };
});

和HTML

<div ng-controller="SimpleController"><div hello-world></div></div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM