javascript - In angular, how can I use ng-if for the containing tag only without the trailing markup -
let's have 2 html elements same tag, each different set of properties. how can conditionally choose between them?
i have following 2 tags:
<a ui-sref="root.one(::{param: value})"> <a target="_blank" href="{{::model}}">
i need conditionally choose 1 of them, , add other markup until closing tag. can work?
<a ng-if="::condition" ui-sref="root.one(::{param: value})"> <a ng-else target="_blank" href="{{::model}}"> <div> more nodes </div> </a>
at end figured impossible, resorted merging tags this:
<a ng-attr-target="{{::!condition? '_blank' : undefined}}" href="{{::model}}" ng-attr-ui-sref="{{::(condition? 'root.one(::{param: value})' : '.')}}">
remarks:
- when condition met, ng-attr-target expression set undefined target attribute not inserted @ all. apparently, if set _self messes angular routing
- when condition not met, ng-attr-ui-sref expression set random undeclared ui-sref route - '.'. set undefined if don't want attribute inserted, there's bug in ui-sref or in angular, results in errors in console had resort method.
Comments
Post a Comment