selected option angularjs

39 views
Skip to first unread message

Znegui Maryam

unread,
Jun 5, 2014, 7:44:20 AM6/5/14
to ang...@googlegroups.com
hello everybody
I want to display input tag according to the selected option 

expl : 

 <select
            ng-model="selection"
            
            <option value="">- - Make Selection - -</option>
            <option value="PP">PP</option>
            <option value="PM">PM</option>
        </select>
 
so if i select PP i want to display <input type="text">
else if I select PM i want to display <input type="number">

thanks a lot 

Karol Siwek

unread,
Jun 6, 2014, 9:41:20 AM6/6/14
to ang...@googlegroups.com
IMHO the best way is to use "ng-if" 

like that:

<div ng-controller="MyCtrl">
    <select ng-model="selection">

        <option value="">- - Make Selection - -</option>
        <option value="PP">PP</option>
        <option value="PM">PM</option>
    </select>

    <input ng-if="selection=='PP'" type="text" />
    <input ng-if="selection=='PM'" type="number" />
</div>

Znegui Maryam

unread,
Jun 6, 2014, 10:16:28 AM6/6/14
to ang...@googlegroups.com
 thanks a lot :))))))))))


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/KkfkDXrXmrA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages