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
Post a Comment