ngroute

What's the most concise way to read query parameters in AngularJS?

血红的双手。 提交于 2019-11-26 03:47:44
问题 I\'d like to read the values of URL query parameters using AngularJS. I\'m accessing the HTML with the following URL: http://127.0.0.1:8080/test.html?target=bob As expected, location.search is \"?target=bob\" . For accessing the value of target , I\'ve found various examples listed on the web, but none of them work in AngularJS 1.0.0rc10. In particular, the following are all undefined : $location.search.target $location.search[\'target\'] $location.search()[\'target\'] Anyone know what will

Redirecting to a certain route based on condition

馋奶兔 提交于 2019-11-26 01:30:34
问题 I\'m writing a small AngularJS app that has a login view and a main view, configured like so: $routeProvider .when(\'/main\' , {templateUrl: \'partials/main.html\', controller: MainController}) .when(\'/login\', {templateUrl: \'partials/login.html\', controller: LoginController}) .otherwise({redirectTo: \'/login\'}); My LoginController checks the user/pass combination and sets a property on the $rootScope reflecting this: function LoginController($scope, $location, $rootScope) { $scope

Removing the fragment identifier from AngularJS urls (# symbol)

懵懂的女人 提交于 2019-11-25 22:57:43
问题 Is it possible to remove the # symbol from angular.js URLs? I still want to be able to use the browser\'s back button, etc, when I change the view and will update the URL with params, but I don\'t want the # symbol. The tutorial routeProvider is declared as follows: angular.module(\'phonecat\', []). config([\'$routeProvider\', function($routeProvider) { $routeProvider. when(\'/phones\', {templateUrl: \'partials/phone-list.html\', controller: PhoneListCtrl}). when(\'/phones/:phoneId\',