AngularJS ui router passing data between states without URL

We can use params, new feature of the UI-Router: API Reference / ui.router.state / $stateProvider params A map which optionally configures parameters declared in the url, or defines additional non-url parameters. For each parameter being configured, add a configuration object keyed to the name of the parameter. See the part: “…or defines additional non-url parameters…” … Read more

How to pass parameters using ui-sref in ui-router to controller

I’ve created an example to show how to. Updated state definition would be: $stateProvider .state(‘home’, { url: ‘/:foo?bar’, views: { ”: { templateUrl: ‘tpl.home.html’, controller: ‘MainRootCtrl’ }, … } And this would be the controller: .controller(‘MainRootCtrl’, function($scope, $state, $stateParams) { //.. var foo = $stateParams.foo; //getting fooVal var bar = $stateParams.bar; //getting barVal //.. $scope.state … Read more

How do I share $scope data between states in angularjs ui-router?

I created working plunker, showing how to use $scope and UI-Router. The state definition is unchanged: $stateProvider // States .state(“main”, { controller:’mainController’, url:”/main”, templateUrl: “main_init.html” }) .state(“main.1″, { controller:’mainController’, parent: ‘main’, url:”/1”, templateUrl: ‘form_1.html’ }) .state(“main.2”, { controller:’mainController’, parent: ‘main’, url: “/2”, templateUrl: ‘form_2.html’ }) But each state can have different controller. Why? because each … Read more