The below code contains 2 views and I want to get the data from index to user.
JS code:
var app=angular.module("myApp",[]);
app.controller("MainController",function($scope,$window,$rootScope)
{
$rootScope.loc={UserName:"",Pwd:""};
$scope.name="";
$scope.check=function()
{
$scope.name=$rootScope.loc.UserName;
if(($rootScope.loc.UserName !="") && ($rootScope.loc.Pwd!=""))
{
alert($scope.name);
$window.location = 'user.html'
}
}
});
main.html
Name: <input type="text" ng-model="loc.UserName">
Pwd: <input type="text" ng-model="loc.Pwd">
<br><br>
<input type="submit" id="submit" value="Award me" ng-click="check()">
user.html
<h1 id="honor" ng-controller="MainController">{{name}}!!!!</h1>