I have an input field which is changing dynamically on some event.
<input name="selectedId" id="selectedId" ng-model="selectedId" type="hidden" on-change="setUrl">
Now I want to redirect the page to that id present in input field when ever it changes.
My controller:
var app = angular.module("myApp", []).
config(function($routeProvider, $locationProvider) {
$routeProvider.
when("/a1", { templateUrl: "partials/page1.html"}).
when("/a2", { templateUrl: "partials/page2.html"}).
otherwise( { redirectTo: "/a1" });
});
app.controller("MainCtrl", function($scope, $location) {
$scope.setUrl=function($scope){
if ($scope.selectedId) {
alert($scope.selectedId);
}
else{
alert("Out of scope");
}
//$location.path($scope.selectedId);
};
Here, I am not able to put the input field value in to scope. I'm not even able to trigger setUrl() so that I can redirect the URL.
I'm new to AngularJS so I need to understand the concept.