angularjs - angular.js and require.js - how to navigate? -


i'm experimenting angular.js , require.js. i'm trying simple login form module. project based on https://github.com/partap/angular-requirejs-seed project.

so, have routes:

angular.module('app', [])     .config([ '$routeprovider',         function ($routeprovider) {             $routeprovider.when('/auth', {                 templateurl : 'forms/auth.html',                 controller : ...             });             $routeprovider.when('/account', {                 templateurl : 'forms/account.html',                 controller : ...             });             $routeprovider.otherwise({ redirectto : '/auth' });         }]); 

so when application starts navigates #/auth. ok. auth controller created follows:

define([ 'angular' ], function (angular) {     return function ($scope) {         ... here ...         ... , redirect /account if credentials valid ...     }; }); 

everything goes until redirection - think should use $location variable somehow, not know how it.

you need pass in dependency module

define([ 'angular' ], function (angular) {     return app.controller('yourcontroller', ['$scope','$location', function ($scope, $location) {         ... here ...         $location.path('/account')     }]); }); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -