<基本href>原因;[$rootScope:infdig]”;错误
<base href> causes "[$rootScope:infdig] " error
我试图通过url将两个参数从first.html
发送到second.html
,并使用routeParams
在second.html
中获取值。我已经将基本标记设置为<base href="file:///D:/abhilash/node/angapp/"/>
,单击按钮时,输入文本框中的参数应该通过url传递。
第一个.html:
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<title></title>
<base href="file:///D:/abhilash/node/angapp/"/>
</head>
<body>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-route.js"></script>
<script type="text/javascript" src="controller.js"></script>
<div ng-controller="firstController">
First name:<input type="text" ng-model="firstName"><br>
Last name:<input type="" ng-model="lastName"><br>
<input type="button" ng-click="loadView()" value="submit" name="">
</div>
</body>
</html>
Second.html:
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<title></title>
<base href="file:///D:/abhilash/node/angapp/"/>
</head>
<body>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-route.js"></script>
<script type="text/javascript" src="controller.js"></script>
<div ng-controller="secondController">
{{firstName}}
</div>
</body>
</html>
这是控制器:
(function(){
var app = angular.module('myapp', ['ngRoute']);
app.config(function($routeProvider,$locationProvider){
$routeProvider.when('/first',{
templateUrl:'/first.html',
controller: 'firstController'
})
.when('/second/:firstName/:lastName',{
templateUrl:'/second.html',
controller:'secondController'
})
.otherwise({
redirectTo:'/first'
})
$locationProvider.html5Mode(true);
})
app.controller('firstController',function($scope,$location){
$scope.firstName="";
$scope.lastName="";
$scope.loadView = function()
{
$location.path('second/'+$scope.firstName +"/" +$scope.lastName);
console.log($location.url());
}
})
.controller('secondController',function($scope,$routeParams){
$scope.firstName = $routeParams.firstName;
$scope.lastName = $routeParams.lastName;
})
}());
在此处检查此代码如果您正在将应用程序部署到根上下文中(例如。https://myapp.com/),将基本URL设置为/:
<head>
<base href="/">
...
</head>
如果您正在将应用程序部署到子上下文中(例如。https://myapp.com/subapp/),将基本URL设置为子文本的URL:
<head>
<base href="/subapp/">
...
</head>
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- Angular JS错误:仅在IE 10和IE 11中出现[$rootScope:infdig]
- AngularJS错误:$rootScope:infdig Infinite$digest循环:达到10次$digest
- 为什么使用CryptoJS的哈希计算会在Angular中导致$rootScope:infdig错误
- AngularJS 错误:$rootScope:infdig 无限$digest循环
- $rootScope:AngularJS应用程序中的infdig错误
- JavaScript 运行时错误:[$rootScope:infdig] 达到 10 次$digest() 迭代.中止!
- 未捕获的错误: [$rootScope:infdig]
- AngularJS:未捕获错误:已达到[$rootScope:infdig]10$digest()迭代
- Angular.js 1.4.7动态ng选项导致多个方法调用和infdig错误
- 在AngularJS中使用ng-disabled来验证元素集合时,会出现$rootScope:infdig错误
- 返回对象时的Angular infdig错误
- <基本href>原因;[$rootScope:infdig]”;错误
- 指令错误 $rootScope:infdig 无限$digest循环
- 错误:[$rootScope:infdig] 10 $digest()迭代到达.流产