我正在AngularJS 1.4.3中创建自定义指令。下面是我的指令代码。
'use strict';
angular.module('psFramework').directive('psFramework', function () {
return {
transclude: true,
scope: {
},
controller: 'psFrameworkController',
templatesUrl: 'ext-modules/psFramework/psFrameworkTemplate.html'
}
});
这是我的控制器 psFrameworkController
'use strict';
angular.module('psFramework').controller('psFrameworkController',
['$scope',
function ($scope) {
}
]);
我的模块 psFrameworkModule
'use strict';
angular.module('psFramework', ['psMenu', 'psDashboard']);
和模板psFrameworkTemplate.html
,这很简单
<h1>Hello</h1>
当我<ps-framework></ps-framework>
在index.html
文件中放置标签时,它就不以某种方式呈现模板。
这是我的 index.html
<body class="container-fluid">
<ps-framework></ps-framework>
</body>
这是templateUrl
不是templatesUrl
和我一样建议加restrict
属性太:
'use strict';
angular.module('psFramework').directive('psFramework', function () {
return {
restrict: 'E',
transclude: true,
scope: {
},
controller: 'psFrameworkController',
templateUrl: 'ext-modules/psFramework/psFrameworkTemplate.html'
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句