简体   繁体   English

Angular指令未在IE11中呈现,但在Chrome中呈现

[英]Angular directive not rendered in IE11 but in Chrome

I am trying to use a custom directive in a module. 我正在尝试在模块中使用自定义指令。 It works in chrome but noch in IE 11 or lower. 它适用于Chrome浏览器,但适用于IE 11或更低版本。

Module controller 模块控制器

angular.module('myApp', [])
    .controller('myCtrl', ['$scope', '$stateParams',
        function ($scope,  $stateParams) {
            'use strict';

            $scope.config = {
                entityId: $stateParams.entityid

            }
        }]);

Module html 模块html

<div data-my-directive data-config="config" />

Directive JS 指令JS

angular.module('myApp').directive('myDirective', ['$state',
        function ($state) {
            'use strict';

            return {
                restrict: 'EA',
                replace: true,
                templateUrl: "template.html",
                scope: {
                    config: "=config"
                },
                link: function ($scope) {
                    'use strict';
                });
            }
        };
    }]);

Directive HTML Hello World 指令HTML Hello World

The "Hello World" is never rendered and the link function is never called. 永远不会渲染“ Hello World”,也永远不会调用链接函数。

Any ideas? 有任何想法吗?

Assuming that you did a straight copy/paste, your problem is here: 假设您进行了直接复制/粘贴,则问题出在这里:

templateUrl: "template.html"),

and here: 和这里:

});

You've got stray closing parenthesis. 您有迷惑的右括号。 Remove them. 删除它们。 Chrome is more forgiving than IE in some cases. 在某些情况下,Chrome比IE更宽容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM