javascript - Angular ng-repeat like parameters binding -
is possible bind angular ng-repeat parameters this:
ng-repeat="[bind_this]"
furthermore, i'd able bind in kind of scenario:
<input type="text" ng-model="customselected" placeholder="custom template" typeahead="state state.name state in stateswithflags | filter:{name:$viewvalue}" typeahead-template-url="customtemplate.html" class="form-control">
would become
<input type="text" ng-model="customselected" placeholder="custom template" typeahead="[bind_this]" typeahead-template-url="customtemplate.html" class="form-control">
thanks
what request not possible without workaround. docs:
the expression indicating how enumerate collection. these formats supported:
variable in expression
– variable user defined loop variable , expression scope expression giving collection enumerate.for example:
album in artist.albums
.(key, value) in expression – key , value can user defined identifiers, , expression scope expression giving collection enumerate.
for example:
(name, age) in {'adam':10, 'amalie':12}
.
variable in expression track tracking_expression
– can provide optional tracking expression can used associate objects in collection dom elements. if no tracking expression specified, ng-repeat associates elements identity. error have more 1 tracking expression value resolve same key. (this mean 2 distinct objects mapped same dom element, not possible.)note tracking expression must come last, after filters, , alias expression.
for example:
item in items
equivalentitem in items track $id(item)
. implies dom elements associated item identity in array.for example:
item in items track $id(item)
. built in$id()
function can used assign unique$$hashkey
property each item in array. property used key associated dom elements corresponding item in array identity. moving same object in array move dom element in same way in dom.for example:
item in items track item.id
typical pattern when items come database. in case object identity not matter. 2 objects considered equivalent longid
property same.for example:
item in items | filter:searchtext track item.id
pattern might used apply filter items in conjunction tracking expression.
variable in expression alias_expression
– can provide optional alias expression store intermediate results of repeater after filters have been applied. typically used render special message when filter active on repeater, filtered result set empty.for example:
item in items | filter:x results
store fragment of repeated itemsresults
, after items have been processed through filter.please note `as [variable name] not operator rather part of ngrepeat micro-syntax can used @ end (and not operator, inside expression).
for example:
item in items | filter : x | orderby : order | limitto : limit results
.
Comments
Post a Comment