Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
- <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.min.js"></script>
- <script src="newcontroller.js"></script>
- <script src="controller.js"></script>
- <link rel="stylesheet" href="stylingpage.css">
- </head>
- <body ng-app="myModule">
- <div ng-controller="myCtrl">
- <h2 align="center">Welcome</h2>
- <table width="20%">
- <thead>
- <tr>
- <th>ID</th>
- <th>UserName</th>
- <th>Password</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="employee in employees">
- <td>{{employee.id}}</td>
- <td>{{employee.name}}</td>
- <td>{{employee.password}}</td>
- <td><button type="button" ng-click="view()">View</button></td>
- </tr>
- </tbody>
- </table>
- </div>
- </body>
- </html>
- var app=angular.module('mainApp',['ngRoute']);
- app.config(function($routeProvider){
- $routeProvider
- .when('/',{
- templateUrl:'login.html'
- })
- .when('/newdashboard',{
- resolve:{
- "check":function($location,$rootScope){
- if(!$rootScope.loggedIn){
- $location.path('/');
- }
- }
- },
- templateUrl:'newdashboard.html'
- })
- .when('/userdetails',{
- templateUrl:'userdetails.html'
- })
- .otherwise({
- redirectTo:'/'
- });
- });
- app.controller('loginCtrl',function($scope,$location,$rootScope){
- $scope.submit=function(){
- if($scope.username=='admin' && $scope.password =='admin'){
- $rootScope.loggedIn=true;
- $location.path('/newdashboard');
- }else{
- alert('wrong Username or password. Try Again');
- }
- };
- });
- app.controller('myCtrl',function($scope){
- $scope.employees=[
- {id:"101",name:"User 1",password:"User1@123"},
- {id:"102",name:"User 2",password:"User2@123"},
- {id:"103",name:"User 3",password:"User3@123"},
- {id:"104",name:"User 4",password:"User4@123"},
- {id:"105",name:"User 5",password:"User5@123"},
- {id:"106",name:"User 6",password:"User6@123"}
- ];
- });
- <td><button type="button" ng-click="view(employee.id)">View</button></td>
- .when('/userdetails/:id',{
- templateUrl:'userdetails.html'
- })
- $scope.view= function(userId) {
- $location.path('/userdetails/').search({id: userId});
- }
- var urlParams = $location.search();
- urlParams.id will return Empolyee Id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement