javascript - Unable to load view through ng-Route with no errors -
view not getting rendered although there no error.
i have added angular-route.js file in head.below mentioned angular js code present in angroute.js file.the html code written in index.html file.i have created 2 html files in view folder named 1>course.html , 2>student.html don't know why url links appear - http://127.0.0.1:57420/index.html#!/index.html
<!doctype html> <html lang="en" ng-app="module"> <head> <meta charset="utf-8"> <title>test</title> <script src="angular-1.6.5/angular.js" type="text/javascript"> </script> <script src="angular-1.6.5/angular-route.js" type="text/javascript"> </script> <script src="angroute.js" type="text/javascript"></script> <style type="text/css"> body{ margin: 0px; padding: 0px; } .menu{ background-color: #26292c; color: aqua; float: left; width: 20%; height: 650px; } .details{ background-color: bisque; float: right; width: 80%; height: 650px } .main{ display:block; } </style> </head> <body> <div class="main"> <div class="menu" ng-controller="hey"> <ol> <li><a href="#/course">course</a></li> <li> <a href="#/student">student</a></li> </ol> </div> <div class="details"> <ng-view></ng-view> </div> </div> </body> </html> var myap=angular.module("module",['ngroute']); myap.config(function($routeprovider){ $routeprovider.when("/course",{ templateurl:"view/course.html", controller:"coursecontroller" }) .when("/student",{ templateurl:"view/student.html", controller:"studentcontroller" }) .otherwise({ redirectto: '/index.html' }) }).controller("coursecontroller",function($scope){ $scope.heading="course page"; }) .controller("studentcontroller",function($scope){ $scope.heading="student page"; }) myap.controller("hey",function($scope){ $scope.heading="hi"; })
Comments
Post a Comment