angular 指令不呈现

angular directive does not render

我在使用 angular 指令时遇到问题。我创建了一个自定义指令,但它没有出现,我也不知道为什么。我可以使用 localhost 访问 templateUrl 中指定的视图。

如果有人能帮助我,那就太好了。

谢谢。

messageListDirective.js

angular.module('neat')
    .directive('message-list', function() {
        return {
            restrict: 'E',
            templateUrl: '/views/utils/messageList.html'
        }
    });

messageList.html

<h4>MESSAGE LIST</h4>

以及我使用指令的视图:

messageBoard.html

<message-list></message-list>

您是否在 messageBoard.html 中导入了 ng-controller="neat" ?
如果是,我认为您应该检查 url 模板。

更改指令:

.directive('message-list', function() { 

.directive('messageList', function() {      

angular 标准化元素标签。阅读本文了解更多 info