AngularJS: ui-router: Do not output link of current state? -


is possible to check state in view , don't output link current (active) state?

currently trying:

<a ng-if="!$state.includes('dashboard.common')" ui-sref="dashboard.common" >dashboard</a> <span ng-if="$state.includes('dashboard.common')">dashboard</span> 

of course, decorate ui-sref-active, don't want have link @ all.

any ideas?

the answer provided here

and final version is:

angular.module('ui')   .directive('uilink', function($state) {     'use strict';      return {       restrict: 'e',       transclude: true,       template: [         '<a ui-sref="{{uisref}}" ng-if="!iscurrent()" ng-transclude></a>',         '<span ng-if="iscurrent()" ng-transclude></span>'       ].join(''),       link: function(scope, element, attrs) {         scope.uisref = attrs.sref;         scope.iscurrent = function() {           return $state.includes(attrs.sref);         };       }     };   }); 

so can use directive like:

<ui-link sref="dashboard.common"><span translate="my_dashboard">dashboard</span></ui-link> 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -