Question: condensing repeated ng-model based on ng-if

Question

condensing repeated ng-model based on ng-if

Answers 1
Added at 2017-11-30 18:11
Tags
Question

I have a block of angular code:

<input ng-if="item.isBulk" ng-model="item.BulkQuantity" />
 .
 .
<input ng-if="item.isCollection" ng-model="item.CollectionQuantity" />

Adhering to the principle of DRY,
Is there a way to reduce this to a one liner in html without javascript?
(actual code has more attributes and a few more inputs that differ only on values
supplied to ng-if and ng-model.
)
Edit:
Only 1 input will evaluate to true.
Having some experience with React's JSX and implementing this in conjunction with
MS ASP's Razor View I felt that this is possible.
With Razor you can inline code with html and
JSX you have javascript 'wrapping' html.

Answers to

condensing repeated ng-model based on ng-if

nr: #1 dodano: 2017-11-30 19:11

HTML does not support conditional logic. Be in mind that HTML is a markup language. You would need to use client-side scripting or server-side code to provide the conditional logic that would render your HTML accordingly.

Keep rocking!

Source Show
◀ Wstecz