selma selma - 25 days ago 9
AngularJS Question

version of ui router params attribut angularjs

i'm using those lib for angualrJs:

<script src="https://code.angularjs.org/1.5.1/angular.js"></script>
<script src="https://code.angularjs.org/1.5.1/angular-route.js"></script>
<script src="https://code.angularjs.org/1.5.1/angular-resource.js"></script>
<script src="https://code.angularjs.org/1.5.1/angular-messages.js"></script>
<script src="https://code.angularjs.org/1.5.1/angular-message-format.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.js"></script>


<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/restangular/1.6.1/restangular.js"></script>

<script src="//cdn.jsdelivr.net/angular.bootstrap/0.12.0/ui-bootstrap-tpls.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.2/angular-translate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.2/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>


I would like to use the parms attribut in stateProvider like:

$stateProvider
.state('home', {
url: '/',
views: {
'': {
templateUrl: 'home.html',
controller: 'MainRootCtrl'

},
},
params: {
foo: null,
bar: null
}
})


but i got alwayse error , which version can i use of angular-ui-router in order to get this functionality, i'm using 0.2.10 because it is compayible with the rest of versiob of lib i'm using

Answer Source

Try like this :

Remove your angular-route in script tag

<script src="https://code.angularjs.org/1.5.1/angular-route.js"></script>

try ti Use angular-ui-router.js version 0.2.11

set params like below

angular
  .module('myApp', [
    'ui.router'
  ])
  .config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state('home', {
        url: '/',
        templateUrl: 'home.html',
        controller: 'MainRootCtrl',
        params: {
             foo: null
        }   
      })
  });