angularjs - Angular js select ng-model binding -
I have a big problem with angular here. Here's my code:
Controller:
function testCt ($ scope) {$ scope.types = [{name: 'fruit', label: 'to do fruit'}, {name: 'meat', label: 'meat'}, {Name: 'other', label: 'other'}]; $ Scope.foods = [{Name: 'apple', type: 'fruit'}, {name: 'raptor', type: 'meat'}]; $ Scope Selected = null; $ Scope Selectionfood = work (food) {$ scope.selected = food; }}; More views:
& lt; Div ng-app ng-controller = "testCt" & gt; & Lt; Ul & gt; & Lt; Li ng-repeat = "food in food" ng-click = "selectionfood (food)" & gt; {{Food.name}} & lt; / Li & gt; & Lt; / Ul & gt; & Lt; Select data-ng-model = 'selected' data-ng-option = 't for type t In the form of LLL '& gt; & Lt; / Select & gt; & Lt; Br> {{Selected.name}} & lt; Br> {{Selected.type}} & lt; / Div & gt; The problem is, angular is not obliged to select JS component which I clicked. Here's the bella:
When I select a meal from the list, the selection element is not bound to type. Thanks for the help :)
Try it out:
Data- NG -Peaction = "T for T type T."
You have to set t as a reference, not the name T (name or type of attributes in t.name No)
Comments
Post a Comment