Angular 指令:来自其他文件的模板
Angular directive: template from other file
如何在 angular js 中包含 .html 作为我的模板文件,而不是在模板属性中直接使用 HTML 代码?`
到目前为止,这是我的代码:
.directive('navigation', ['$rootScope', '$i18next', function ($rootScope: any, $i18next: any) {
return {
bindToController: true,
template: '../views/navigation-directive.html',
link: function (scope, element, attrs) {....
但是当 运行 这段代码时,我的浏览器唯一显示的是明文形式的 '../views/navigation-directive.html'。
我的文件的当前结构是这样的。
指令文件位于solution/script/navigation.js
.html 文件位于 solution/view/navigation-directive.html
更改道具
template: '../views/navigation-directive.html',
至
templateUrl: '../views/navigation-directive.html',
如何在 angular js 中包含 .html 作为我的模板文件,而不是在模板属性中直接使用 HTML 代码?`
到目前为止,这是我的代码:
.directive('navigation', ['$rootScope', '$i18next', function ($rootScope: any, $i18next: any) {
return {
bindToController: true,
template: '../views/navigation-directive.html',
link: function (scope, element, attrs) {....
但是当 运行 这段代码时,我的浏览器唯一显示的是明文形式的 '../views/navigation-directive.html'。
我的文件的当前结构是这样的。
指令文件位于solution/script/navigation.js .html 文件位于 solution/view/navigation-directive.html
更改道具
template: '../views/navigation-directive.html',
至
templateUrl: '../views/navigation-directive.html',