自定义AngularJS指令不起作用

Om3ga

我正在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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章