- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
开发应用程序并尝试使用最新的稳定和不稳定版本的 angularJS该应用程序在除 IE 9 和 IE8(可能更低)之外的所有浏览器上都能正常加载
尝试调试它,监听它的对象似乎从未收到 $locationChangeSuccess 广播 $rootScope.$on('$locationChangeSuccess', updateRoute);因此永远不会调用 updateRoute 方法。不过,会调用 afterLocationChange 函数。由于在 IE8debugger 中运行的糟糕的 IE10(不会在我在 angularJS 中设置的断点上中断),我无法进行调试,因此使用了 console.log 输出。
我正在手动引导,并且有一种特定的路由方式,不使用 ng-views 而是使用 ng-include/ng-switch 并向路由添加一个操作属性,然后由主 Controller 评估该操作属性并将其注入(inject)到 View 用于 ng-switch 的范围。我不知道这是否与我路由的方式有关,因为看起来 updateRoute 从未被调用过,但无论如何我这里都是代码,以防我错了。
路由定义功能(登录)
{
LOGIN.config
(
[
'$routeProvider', '$locationProvider', '$dialogProvider',
function ($routeProvider, $locationProvider, $dialogProvider)
{
$locationProvider.html5Mode(true).hashPrefix = '!';
$routeProvider
.when("/", { action: "login" })
.when("/forgot_password/", { action: "forgot_password" });
}
]
);
}
应用程序 Controller
function (LOGIN)
{
LOGIN.controller(
'controllerApplication',
[
'$scope', '$route',
function ($scope, $route) {
var self = this;
// Update the rendering of the page.
this.render = function ()
{
// Pull the "action" value out of the currently selected route.
var renderAction = $route.current.action;
// Also, let's update the render path so that we can start conditionally rendering parts of the page.
var renderPath = renderAction.split(".");
// Reset the boolean used to set the css class for the navigation.
var inLogin = (renderPath[0] === "login");
var inPassword = (renderPath[0] === "forgot_password");
// Store the values in the model.
$scope.renderAction = renderAction;
$scope.renderPath = renderPath;
$scope.inLogin = inLogin;
$scope.inPassword = inPassword;
$scope.loaded = false;
};
// Listen for changes to the Route.
// When the route changes, let's set the renderAction model value
// so that it can render in the Strong element.
$scope.$on
(
"$routeChangeSuccess",
function ($currentRoute, $previousRoute)
{
// Update the rendering.
self.render();
}
);
}
]
);
}
在我的部分
<div id="main-container" ng-switch on="renderPath[0]">
<div ng-switch-when="login" ng-include=" 'js/app/login/partials/login.html' "></div>
<div ng-switch-when="forgot_password" ng-include=" 'js/app/login/partials/forgot-password.html' "></div>
</div>
我在这里记录了一个错误 https://github.com/angular/angular.js/issues/2608
但是没有人遇到这个问题似乎很奇怪,所以我很想得到人们的一些意见。
我还没有看到在 IE8 中运行的应用程序。
如果您有任何链接,我将很乐意查看。干杯。
最佳答案
我感到很羞耻...:)
花了一个小时调试并发现 Angular 没有找到 IE 的 ng-controller 指令后,我意识到我忘记在 IE 特定的 html 指令中包含相同的 Controller ......
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en" ng-controller="controllerApplication"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en" ng-controller="controllerApplication"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en" ng-controller="controllerApplication"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js" lang="en" ng-controller="controllerApplication"> <![endif]-->
关于javascript - AngularJS - IE8 IE9 永远不会调用 updateRoute 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16452292/
开发应用程序并尝试使用最新的稳定和不稳定版本的 angularJS该应用程序在除 IE 9 和 IE8(可能更低)之外的所有浏览器上都能正常加载 尝试调试它,监听它的对象似乎从未收到 $locatio
我是一名优秀的程序员,十分优秀!