Set Page title using UI-Router

Use $stateChangeSuccess. You can put it in a directive: app.directive(‘updateTitle’, [‘$rootScope’, ‘$timeout’, function($rootScope, $timeout) { return { link: function(scope, element) { var listener = function(event, toState) { var title=”Default Title”; if (toState.data && toState.data.pageTitle) title = toState.data.pageTitle; $timeout(function() { element.text(title); }, 0, false); }; $rootScope.$on(‘$stateChangeSuccess’, listener); } }; } ]); And: <title update-title></title> Demo: http://run.plnkr.co/8tqvzlCw62Tl7t4j/#/home … Read more

Difference between $state.transitionTo() and $state.go() in Angular ui-router

Are you referring to the AngularUI Router? If so, the wiki specifies the differences: $state.go(to [, toParams] [, options]) Returns a Promise representing the state of the transition. Convenience method for transitioning to a new state. $state.go calls $state.transitionTo internally but automatically sets options to { location: true, inherit: true, relative: $state.$current, notify: true }. … Read more

How to pass an object into a state using UI-router?

In version 0.2.13, You should be able to pass objects into $state.go, $state.go(‘myState’, {myParam: {some: ‘thing’}}) $stateProvider.state(‘myState’, { url: ‘/myState/{myParam:json}’, params: {myParam: null}, … and then access the parameter in your controller. $stateParams.myParam //should be {some: ‘thing’} myParam will not show up in the URL. Source: See the comment by christopherthielen https://github.com/angular-ui/ui-router/issues/983, reproduced here for … Read more

Injecting $state (ui-router) into $http interceptor causes circular dependency

The Fix Use the $injector service to get a reference to the $state service. var interceptor = [‘$location’, ‘$q’, ‘$injector’, function($location, $q, $injector) { function success(response) { return response; } function error(response) { if(response.status === 401) { $injector.get(‘$state’).transitionTo(‘public.login’); return $q.reject(response); } else { return $q.reject(response); } } return function(promise) { return promise.then(success, error); } }]; … Read more

`ui-router` $stateParams vs. $state.params

The documentation reiterates your findings here: https://github.com/angular-ui/ui-router/wiki/URL-Routing#stateparams-service If my memory serves, $stateParams was introduced later than the original $state.params, and seems to be a simple helper injector to avoid continuously writing $state.params. I doubt there are any best practice guidelines, but context wins out for me. If you simply want access to the params received … Read more

How to send and retrieve parameters using $state.go toParams and $stateParams?

If you want to pass non-URL state, then you must not use url when setting up your state. I found the answer on a PR and did some monkeying around to better understand. $stateProvider.state(‘toState’, { templateUrl:’wokka.html’, controller:’stateController’, params: { ‘referer’: ‘some default’, ‘param2’: ‘some default’, ‘etc’: ‘some default’ } }); Then you can navigate to … Read more

AngularJS UI Router – change url without reloading state

Simply you can use $state.transitionTo instead of $state.go . $state.go calls $state.transitionTo internally but automatically sets options to { location: true, inherit: true, relative: $state.$current, notify: true } . You can call $state.transitionTo and set notify: false . For example: $state.go(‘.detail’, {id: newId}) can be replaced by $state.transitionTo(‘.detail’, {id: newId}, { location: true, inherit: true, … Read more

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

Angular – ui-router get previous state

I use resolve to save the current state data before moving to the new state: angular.module(‘MyModule’) .config([‘$stateProvider’, function ($stateProvider) { $stateProvider .state(‘mystate’, { templateUrl: ‘mytemplate.html’, controller: [“PreviousState”, function (PreviousState) { if (PreviousState.Name == “mystate”) { // … } }], resolve: { PreviousState: [“$state”, function ($state) { var currentStateData = { Name: $state.current.name, Params: angular.copy($state.params), URL: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)