I want to pass my first view textbox value to another view textbox. and both of that view are using a different controller.
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title></title>
</head>
<body>
<div ng-view="">
</div>
</body>
</html>
<script src="../Scripts/angular.min.js"></script>
<script src="../Scripts/angular-route.min.js"></script>
<script src="../Scripts/routeApp.js"></script>
<script src="../Scripts/Controller.js"></script>
This is my main page on which View1 and view2 HTML file will load.
"View1"
<div>
<input type="text" name="fname" value="" ng-model="fname" />
<a href="#/View2" >Link</a>
</div>
"View2"
<div>
<input type="text" name="fname" value="" ng-model="fname" />
</div>
"routeApp.js"
var myApp = angular.module('myApp', ['ngRoute', 'yourApp']);
debugger
myApp.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/',
{
templateUrl: 'View1.html',
controller: 'View1'
}).
when('/View2',
{
templateUrl: 'View2.html',
controller: 'View2'
}).
otherwise(
{
redirectTo: '/'
});
}]);
"Controller.js"
var yourApp = angular.module("yourApp",[]);
yourApp.controller("View1", function ($rootScope, $scope) {
debugger;
$rootScope.abc = $scope.fname;
});
yourApp.controller("View2", function ($rootScope, $scope) {
debugger;
$scope.fname = $rootScope.abc;
});
My call is coming to controller but I know I did a mistake beacause of that i am not getting my value on View2.html page.