Dynamically generated drop downs [duplicate]











up vote
2
down vote

favorite













This question already has an answer here:




  • Why mixing interpolation and expressions is bad practice

    2 answers




I am trying to generate dynamically inputs with angular and angular material. Whenever the user clicks on the Add button a new dropdown needs to be generated. Right now I got the following error :




'Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{choiceTest.Name}}] starting at [{choiceTest.Name}}].'




How do I need to modify my code to work properly?



<div ng-repeat="choiceTest in $ctrl.inputsFilterRowsTest">
<md-input-container flex="30">
<label>Filter Type</label>
<md-select ng-model={{choiceTest.Name}} name="">
<md-option ng-repeat="filter in $ctrl.filters" value="{{filter.value}}">
{{filter.value}}
</md-option>
</md-select>
</md-input-container>
</div>
<md-button class="md-raised" ng-click="$ctrl.addFilterTest()">ADD</md-button>


Controller



self.inputsFilterRowsTest = ;

self.filters = [
{ value: 'Filter1' },
{ value: 'Filter2' },
{ value: 'Filter3' }
];

self.addFilterTest = function () {
var newItemTestNo = self.inputsFilterRowsTest.length + 1;
self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });
};









share|improve this question















marked as duplicate by georgeawg angularjs
Users with the  angularjs badge can single-handedly close angularjs questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 0:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
    – georgeawg
    Nov 12 at 0:24















up vote
2
down vote

favorite













This question already has an answer here:




  • Why mixing interpolation and expressions is bad practice

    2 answers




I am trying to generate dynamically inputs with angular and angular material. Whenever the user clicks on the Add button a new dropdown needs to be generated. Right now I got the following error :




'Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{choiceTest.Name}}] starting at [{choiceTest.Name}}].'




How do I need to modify my code to work properly?



<div ng-repeat="choiceTest in $ctrl.inputsFilterRowsTest">
<md-input-container flex="30">
<label>Filter Type</label>
<md-select ng-model={{choiceTest.Name}} name="">
<md-option ng-repeat="filter in $ctrl.filters" value="{{filter.value}}">
{{filter.value}}
</md-option>
</md-select>
</md-input-container>
</div>
<md-button class="md-raised" ng-click="$ctrl.addFilterTest()">ADD</md-button>


Controller



self.inputsFilterRowsTest = ;

self.filters = [
{ value: 'Filter1' },
{ value: 'Filter2' },
{ value: 'Filter3' }
];

self.addFilterTest = function () {
var newItemTestNo = self.inputsFilterRowsTest.length + 1;
self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });
};









share|improve this question















marked as duplicate by georgeawg angularjs
Users with the  angularjs badge can single-handedly close angularjs questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 0:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
    – georgeawg
    Nov 12 at 0:24













up vote
2
down vote

favorite









up vote
2
down vote

favorite












This question already has an answer here:




  • Why mixing interpolation and expressions is bad practice

    2 answers




I am trying to generate dynamically inputs with angular and angular material. Whenever the user clicks on the Add button a new dropdown needs to be generated. Right now I got the following error :




'Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{choiceTest.Name}}] starting at [{choiceTest.Name}}].'




How do I need to modify my code to work properly?



<div ng-repeat="choiceTest in $ctrl.inputsFilterRowsTest">
<md-input-container flex="30">
<label>Filter Type</label>
<md-select ng-model={{choiceTest.Name}} name="">
<md-option ng-repeat="filter in $ctrl.filters" value="{{filter.value}}">
{{filter.value}}
</md-option>
</md-select>
</md-input-container>
</div>
<md-button class="md-raised" ng-click="$ctrl.addFilterTest()">ADD</md-button>


Controller



self.inputsFilterRowsTest = ;

self.filters = [
{ value: 'Filter1' },
{ value: 'Filter2' },
{ value: 'Filter3' }
];

self.addFilterTest = function () {
var newItemTestNo = self.inputsFilterRowsTest.length + 1;
self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });
};









share|improve this question
















This question already has an answer here:




  • Why mixing interpolation and expressions is bad practice

    2 answers




I am trying to generate dynamically inputs with angular and angular material. Whenever the user clicks on the Add button a new dropdown needs to be generated. Right now I got the following error :




'Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{choiceTest.Name}}] starting at [{choiceTest.Name}}].'




How do I need to modify my code to work properly?



<div ng-repeat="choiceTest in $ctrl.inputsFilterRowsTest">
<md-input-container flex="30">
<label>Filter Type</label>
<md-select ng-model={{choiceTest.Name}} name="">
<md-option ng-repeat="filter in $ctrl.filters" value="{{filter.value}}">
{{filter.value}}
</md-option>
</md-select>
</md-input-container>
</div>
<md-button class="md-raised" ng-click="$ctrl.addFilterTest()">ADD</md-button>


Controller



self.inputsFilterRowsTest = ;

self.filters = [
{ value: 'Filter1' },
{ value: 'Filter2' },
{ value: 'Filter3' }
];

self.addFilterTest = function () {
var newItemTestNo = self.inputsFilterRowsTest.length + 1;
self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });
};




This question already has an answer here:




  • Why mixing interpolation and expressions is bad practice

    2 answers








javascript angularjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 0:20









georgeawg

32.3k104966




32.3k104966










asked Nov 12 at 0:09









Lio Programista

578




578




marked as duplicate by georgeawg angularjs
Users with the  angularjs badge can single-handedly close angularjs questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 0:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by georgeawg angularjs
Users with the  angularjs badge can single-handedly close angularjs questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 0:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
    – georgeawg
    Nov 12 at 0:24














  • 1




    Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
    – georgeawg
    Nov 12 at 0:24








1




1




Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
– georgeawg
Nov 12 at 0:24




Remove the interpolation from the ng-model directive, e.g. ng-model="choiceTest.Name" without the curley brackets {{ }}.
– georgeawg
Nov 12 at 0:24












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










I think the problem might be capitalization: .name vs. .Name:





  • Template:



     {{choiceTest.Name}}



  • Code:



     self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });







share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    I think the problem might be capitalization: .name vs. .Name:





    • Template:



       {{choiceTest.Name}}



    • Code:



       self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });







    share|improve this answer

























      up vote
      2
      down vote



      accepted










      I think the problem might be capitalization: .name vs. .Name:





      • Template:



         {{choiceTest.Name}}



      • Code:



         self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });







      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        I think the problem might be capitalization: .name vs. .Name:





        • Template:



           {{choiceTest.Name}}



        • Code:



           self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });







        share|improve this answer












        I think the problem might be capitalization: .name vs. .Name:





        • Template:



           {{choiceTest.Name}}



        • Code:



           self.inputsFilterRowsTest.push({ 'value': 'inputFilter' + newItemTestNo, 'name': 'inputFilter' + newItemTestNo });








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 0:18









        paulsm4

        76.4k999124




        76.4k999124















            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine