如何使用指令在Angular中加载外部模板?
角,
app.directive('helloWorld', function() {
return {
restrict: 'AE',
replace: true,
//templateUrl points to an external html template.
emplateUrl: 'fixture/main.html'
};
});
HTML,
夹具/ main.html中,
<div ng-controller="SimpleController">{{sayHello()}}</div>
什么都没有加载。知道我错过了什么吗?
答案 0 :(得分:1)
使用此
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>