tri_inn

tri_inn

  • NA
  • 1.2k
  • 232.4k

AngularJS: How to pass multiple querystring to controller

May 2 2017 9:51 AM
how to work with multiple query string  ?
  1. <a href="#/?car=yes">With Params</a>  
  2. <a href="#/">No Params</a>  
  3. <div ng-view></div>  
  4.    
  5. var myApp = angular.module('myApp', []);  
  6.   
  7. myApp.config(function ($routeProvider) {  
  8. $routeProvider.when('/', {  
  9. template: '<div flash></div><h3>Params Example</h3><p>car: {{car}}</p>',  
  10. controller: indexCtrl  
  11. });  
  12. });  
  13.   
  14. function indexCtrl ($scope, $routeParams) {  
  15. console.log('1');  
  16. if ($routeParams.car) {  
  17. $scope.car = $routeParams.car;  
  18. else {  
  19. $scope.car = 'Not Provided';  
  20. }  
  21. }  
 

Answers (1)