在您的控制器上放置一个方法来执行重定向,然后
ng-click在按钮上调用。
标记:
<button ng-click="goLogin()">Log in</button>
控制器:
.controller('LoginCtrl', function($scope, $location) { $scope.form = { username: null, password: null }; $scope.goLogin = function() { $location.url('http://test.com/login.jsp?un='+ $scope.form.username +'&pw="+ $scope.form.password); };})还要注意要拨打
$location.url()不
path()
要么…
添加
$location到您的范围并调用
url({{newUrl}}):$controller('MyCtrl', function($scope, $location) { $scope.$location = $location;})我仍然会在范围上使用调用方法。



