Linked Questions
17 questions linked to/from Ternary operator in AngularJS templates
1 vote
1 answer
9k views
How to use ternary in ng-init in AngularJS? [duplicate]
Is it possible to use ternary operator in ng-init in AngularJS ? Something like : <select ng-model="project" name="act" ng-options="act.user_id as act.user_display_name for act in actors" ng-init="...
0 votes
1 answer
2k views
angularjs simple conditional [duplicate]
I know I can use ng-if to do conditionals like this: td.icon(ng-if="isAuthor()", colspan="2") td.icon(ng-if="!isAuthor()", colspan="3") But it seems a bit over-wordy for something simple. Is ...
152 votes
9 answers
129k views
angularjs: ng-src equivalent for background-image:url(...)
In angularjs you have the tag ng-src which has the purpose that you won't receive an error for an invalid url before angularjs gets to evaluate the variables placed in between {{ and }}. The problem ...
71 votes
3 answers
162k views
Conditional logic in AngularJS template
I have an angular template which looks like this... <div ng-repeat="message in data.messages" ng-class="message.type"> <div class="info"> <div class="type"></div> ...
94 votes
2 answers
125k views
Accessing attributes from an AngularJS directive
My AngularJS template contains some custom HTML syntax like: <su-label tooltip="{{field.su_documentation}}">{{field.su_name}}</su-label> I created a directive to process it: .directive('...
33 votes
3 answers
52k views
Inline-logic in templates in AngularJS
Is there any way to write logic inline in a template in AngularJS. What I want to do is something like this: <div ng-repeat="item in items"> {{item.isValid ? 'Valid item' : 'Invalid Item'}}...
15 votes
2 answers
32k views
AngularJS - Can I use data binding value depending on ternary operator
I have an ng-repeat li elements and I want to set a specific value for that li depending on whether a function returns true or false and I don't want to do it in the controller because I have ...
4 votes
4 answers
5k views
Javascript ternary operator (?:) change and return object in single block
Is it possible inside ?: change dictionary and return this dictionary in the same block. Something like this a > b ? <dict['c'] = 'I'm changed', return dict> : <some other code>; I ...
1 vote
1 answer
1k views
How to catch the toggle event of angular bootstrapUI accordion
I am working on the angular bootstrapUI accordion, I need to catch the toggle event for each section, for example, in each header of section, I have a arrow, when it is open the arrow-down will show,...
1 vote
1 answer
2k views
Does Angular allow ternary operator?
Got error with ng-style. Doesn't Angular allow ternary operator? I saw a SO post that shows Angular does support ternary operator, but not sure why it doesn't work for me. Error: [$parse:syntax] ...
1 vote
1 answer
1k views
ng-class not responding to change in model in Angular?
Having searched extensively, got some help from A ternary in templates and getting partially functional results, I'm 99% sure I'm doing it 99% right, but...obviously not completely, so I'm here. The ...
0 votes
2 answers
863 views
AngularJS versioning
This is a newbie question. On the AngularJS site, there is a link to download AngularJS. The download button says "1.0.8/1.2.0-rc.2". I'm confused. Which version of AngularJS am I downloading? The ...
1 vote
1 answer
460 views
Is there a way to conditionally add filter inline?
I tried this, but it doesn't work: {{!filterNameVar ? valueVar : valueVar | filterNameVar}} I need it for my dataGrid, if I get a filterName from dataGrid settings for a column I should apply it. I ...
0 votes
1 answer
428 views
Angular Js binding text input with model
I am using a very simple code to bind the user text input to the model. The text box prompts the user to enter the name & says hello "username" on enter. But I also want Hello to appear only when ...
0 votes
2 answers
71 views
Angular logic for repeater
I have a simple repeater setup like so <ion-item ng-repeat="location in data.posts"> {{location.title}} </ion-item> And of course for every array I get a title inside an ion-item. Now ...