0

Hi i'm trying to pass a parameter from page A to B.let's say you get a name from user in page A and want to show it in page B.

I Googled a lot but there is not a working result so i can see how all parts work together.

Q :I know i need to use $stateParams here but how it's unclear for me.

Thanks is advance.

Mojtaba
  • 733
  • 4
  • 12
  • 26

1 Answers1

2

Below is an example of state params being used:

var app = angular.module('app', [])
app.config(function($stateProvider){
  $stateProvider
  .state('sample', {
    url: '/sample/:name',
    templateUrl: '.sampleView.html',
    controller: 'SampleController'
 })

 app.controller('SampleController', function($stateParams) {
   //access params by using $stateParams.<param name>
    var name = $stateParams.name;
 }

The scenario you described sounds more like something where you would want to use a factory/service or maybe even some browser caching.

hii
  • 100
  • 2
  • 8