gpt4 book ai didi

javascript - 如何在 Angular 中使用指令加载外部模板?

转载 作者:行者123 更新时间:2023-12-03 11:30:02 25 4
gpt4 key购买 nike

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

Angular ,

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

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

html,

fixture/main.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>

关于javascript - 如何在 Angular 中使用指令加载外部模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26772544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com