How to detect current state within directive

后端 未结 5 2099
臣服心动
臣服心动 2020-12-07 10:36

I\'m using AngularUI\'s routing and I\'d like to do a ng-class=\"{active: current.state}\" but I\'m unsure how to exactly detect the current state in a directiv

5条回答
  •  旧时难觅i
    2020-12-07 11:20

    If you are using ui-router, try $state.is();

    You can use it like so:

    $state.is('stateName');

    Per the documentation:

    $state.is ... similar to $state.includes, but only checks for the full state name.

提交回复
热议问题