I use ngRoute to route my AngularJS application (myApp), but I have a problem: I donβt know how to NOT APPLY my index.html project (with all my login.html ) for my login.html , which apparently applied by default if it is defined as a view. I want a simple design for my login.html page: there are only two fields to fill in, without the design of my index.html , which applies to all views in myApp. Thus, I do not know how to perform my routing in order to perform such a task. Thank you very much.
<- This is an example of how I perform my routing in myApp (for only one view - "/ view1") β
Example app.js :
'use strict'; // Declare app level module which depends on views, and components angular.module('myApp', [ 'ngRoute', 'ngResource', 'ui.bootstrap', 'ngCookies', 'myApp.view1', ]) .config(['$routeProvider', function($routeProvider) { $routeProvider.otherwise({redirectTo: '/view1'}); }]);
For each view, there is a .js file in which I determined its routing and controllers. For example, for the view "/ view1" - view1.js :
'use strict'; angular.module('myApp.view1', ['ngRoute', 'ngResource']) .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/view1', { templateUrl: 'view1.html', controller: 'View1Ctrl' }); }]) .controller('View1Ctrl', ['$scope', function($scope) {
And a sample of my index.html :
<!doctype html> <html lang="en" ng-app="myApp"> <head> <script src="view1.js"></script> <-- MORE SCRIPTS ARE LOADED --> </head> <body class="hamburg" ng-controller="MasterCtrl"> <-- SIDEBARS ARE DEFINED --> <div id="content-wrapper"> <div class="page-content"> <div class="row"> <div class="col-xs-12"> <div class="widget"> <div class="widget-body"> <div ng-view></div> </div> </div> </div> </div> </div> </div> </body>