Super-simple AngularJS app I\'m trying to build, to accept credentials into two text boxes, then use two-way binding to redirect on a button click to a url which includes th
Put a method on your controller to do the redirect and have that called form the ng-click
on your button.
Markup:
Controller:
.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);
};
})
Also note you want to call $location.url()
not path()
OR...
Add $location
to your scope and call url({{newUrl}})
:
$controller('MyCtrl', function($scope, $location) {
$scope.$location = $location;
})
I'd still go with calling method on the scope.