javascript - AngularJS, $routeProvider -


I am trying to learn the ways in which angrarias can be used so that the users can login a bit and users To login and write comments. live feed. However, the full concept of the routes is a bit blurred for the ATM and I can not get this right.

My standard index.html has an NG-view and required scripts I

  & lt ;! DOCTYPE html & gt; & Lt; Html ng-app = "myApp" & gt; & Lt; Top & gt; & Lt; Script src = "// ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.3/angular.js"></script> & Lt; Script src = "// ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.3/angular-route.js"></script> & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script> & Lt; Script src = "// cdn.firebase.com/js/client/1.0.21/firebase.js"></script> & Lt; Script src = "// cdn.firebase.com/libs/angularfire/0.8.2/angularfire.js"></script> & Lt; Script src = "// cdn.firebase.com/js/simple-login/1.6.3/firebase-simple-login.js"></script> & Lt; Script src = "controller.js" & gt; & Lt; / Script & gt; & Lt; Title & gt; Test login app & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div class = "container" & gt; & Lt; Div ng-view & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

Module and root driver with my controller

  var myApp = angular.module ('myApp', ['NGMNET', 'NGQQs', 'NGRSOSRAR' , 'NGRUT', 'NGSNative', 'NinjaTouch', 'Firebase', 'Firebase.tiles', 'Simple Login']); When ('/ chatt', {administrator: MyController, templateUrl: 'chat') myApp.config .html '}). When ('/ login', {administrator: login Ctrl, templateUrl: 'login.html'}). Otherwise ({redirectTo: '/ handler'})}}; MyApp.config (['$ locationProvider', function ($ location provider) ($ locationProvider.html5Mode (true);}] myApp.controller ('MyController', ['$ scope', '$ firebase', function ($ radius) ), $ Firebase) // Receive the message as a RRE = new firebase ("https://ivproj.firebaseio.com/") // // as an AREE for a firebase reference. Message = $ Firebase (referee) ). $ AsArray (); // ADD message method $ scope.addMessage = function (e) {// Listen for return key (e.keycode === 13 & amp; $ scope.msg) {// Permission custom Or add fun USER NAMES var name = $ scope.name || 'anonymous'; // FIREBASE $ scope.messages $ Add ($ {name: body: $ scope.msg}); // reset message $ scope.msg = ""}}}}]); The $ Routeprovider function should direct me to the handler, which is a simple .html file that has two buttons that in turn redirects to other HTMLs.  

  myApp.config (function ($ route provider) {$ routeProvider. When ('/' when ('/ When ('/ login', {administrator: 'loginCtrl', templateUrl: 'login.html'}). (Otherwise ({redirectTo: 'login.html' '/ Handler'})}};   

The code in the code above $ routeProvider.when () actually creates One path along with the configuration and three . When () are creating three separate routes

but your $ routeProvider.otherwise ('/ hand In ''), you are asking angular to go to the path named / handler if the user tries to navigate anywhere outside the configured routes

The mistake you make is that, you have not defined a path on / handler . Need to define and then use it . Otherwise () .

Try changing your configuration to reflect the bottom. MyApp.config (function ($ migration provider, $ location provider) {$ locationProvider.html5Mode (true); $ pathpad when ('/ handler', {controller: 'handleCtrl', templateUrl: 'handler.html'}) .When ('/ login', {administrator: 'loginCtrl', templateUrl: 'login.html'}). otherwise ({/ RedirectTo: '/ handler'});});

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -