- 6 months ago 94
AngularJS Question

Angular js : How to access $state current page name and params in html

I have multiple pages those I want to change as per states
I am using ui-routes for managing routing.
I want to access $ in html.

<div ng-repeat="que in questions.Cars">

I want to change dynamically as below

<div ng-repeat="que in questions.$">

So that I could traverse page wise questions.

Plunker for complete code


Include the $state service in your controller. Than you can assign this service to a property on your scope.


$scope.$state = $state;

Then to get the current state in your templates:


To get the current state and params in your templates use $state.includes(stateName [, params]):

$state.includes('', {id: 1}); // returns true