$ window.location.href是未定义与angularjs [英] $window.location.href is undefined with angularjs
本文介绍了$ window.location.href是未定义与angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在编写ASP.NET MVC6,angularjs和Bootstap的应用程序。
我想引导模式结束后重新加载页面。
要做到这一点,我用$ window.location.href但它是不确定的。
I programme an application in ASP.NET MVC6, angularjs and Bootstap. I want reload a page after bootstrap modal closing. To do this, I use $window.location.href but it's undefined.
这是我的角度控制方式:
This is my method in angular Controller:
angular
.module('LSapp')
.controller('CustomersCtrl', CustomersCtrl);
CustomersCtrl.$inject = ['$scope', '$http', '$location', '$modal', '$templateCache', '$window'];
function CustomersCtrl($scope, $http, $location, $modal, $window) {
$scope.edit = function(id)
{
var customer = getCustomer(id);
console.log('Customer => FirstName : ' + customer.FirstName);
var reqEditCustomer = $http({ url: '/api/customers/', dataType: 'json', method: 'PUT', data: JSON.stringify(customer), contentType: 'application/json; charset=utf-8' });
reqEditCustomer.success(function (dataResult) {
$scope.customer = dataResult;
$scope.cancel();
});
$scope.customers = getListCustomers();
$window.location.href = '/';
}
}
除了重定向所有运行。
All runs except the redirection.
我希望有人能帮助我。任何帮助是值得欢迎的。
I hope someone can help me . Any help is welcome.
推荐答案
我解决了使用,而不是NG -router ui.router的问题。
I solved the problem by using ui.router instead of ng -router.
这篇关于$ window.location.href是未定义与angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文