【发布时间】:2014-05-01 08:52:43
【问题描述】:
我有在 IE10 兼容模式下崩溃的 angularJS(AngularJS v1.3.0-beta.3) 应用程序。它在 FF、Chrome 和 IE11 中运行良好。这是我在控制台中得到的错误:
Multiple directives [login, login] asking for 'login' controller on: <div>
为了设置应用程序的状态,我创建了一个节点:
link: function ($scope, $element, $attrs) {
....
$element.html('<login></login>');
$compile($element.contents())($scope); // crash happens here
....
}
这是我的登录指令:
widgets.directive('login', ['$compile', '$http', 'resourceLoader', function ($compile, $http, resourceLoader) {
return {
restrict: 'AE',
replace: true,
template: '<div></div>',
controller: function ($scope, $element) {
$scope.user.isLogged = false;
$scope.user.password = undefined;
$scope.submitLogin = function () {
// code that goes to server
};
},
link: function ($scope, $element, $attrs) {
resourceLoader.get('templates', 'profile', 'unlogged/login', 'jquery.min', function (template) {
$element.html(template);
$compile($element.contents())($scope);
});
}
};
}]);
有什么想法吗?谢谢。
【问题讨论】:
-
如何在 index.html 文件中初始化 ng-app??
-
window.onload = function(){angular.bootstrap(document,["myWidgets"]);};
-
你不使用 样式吗?
-
我可以在 IE8+ 上运行 angularjs 1.2.1x。 IE7不能,但我不在乎。
-
@BKM,不,我不是。我必须支持由另一个编码器启动的应用程序。
标签: javascript angularjs internet-explorer-10 ie8-compatibility-mode