Wednesday, 15 September 2010

javascript - How to add boolean attributes to directive? -



javascript - How to add boolean attributes to directive? -

in html, there attributes selected attribute:

<option selected>this alternative selected</option>

it's either nowadays or not present, translates on/off (boolean).

i can't find way create attribute angularjs directive. there way?

an illustration be:

<modal ng-show="modal.show" with-backdrop> // "with-backdrop" boolean attribute.

it's going different depending on you're doing. in example, want know alternative selected. found checking model <select> see what's in it. example:

<select data-ng-model="user.defaultthing" data-ng-options="thing.id thing.name thing in thingcollection"> <option value="">none</option> </select>

with setup, time selection changed, thing.id stored in user.defaultthing.

nb: 'none' alternative have there, allows null selection.

now, if looking see if checkbox checked, it's similar you'd see what's in model it's tied to.

<input type="checkbox" data-ng-model="form.someoption">

when go process form, see if form.someoption true or false.

javascript angularjs attributes angularjs-directive

No comments:

Post a Comment