2016-04-15 25 views
0

Ich erhalte den folgenden Fehler beim Versuch, die Validierungsnachricht mit Angular.js anzuzeigen.Fehler beim Versuch, Validierungsnachricht mit Angular.js anzuzeigen

Error:

angularjs.js:107 Error: [$parse:syntax] http://errors.angularjs.org/1.4.6/$parse/syntax?p0=%7B&p1=is%20an%20unexpected%20token&p2=17&p3=billdata.upload_%7B%7BNaNndex%7D%7D.%24touched&p4=%7B%7B%index%7D%7D.%24touched 

Ich erkläre unter meinem Code.

<div class="input-group bmargindiv1 col-md-12" ng-repeat="mul in mulImage"> 
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Image{{$index+1}}:</span> 
<div> 
<div ng-class="{'myError': billdata.upload_{{$index}}.$touched && billdata.upload_{{$index}}.$invalid }"> 
<input type="file" class="filestyle form-control" data-size="lg" name="upload_{{$index}}" id="bannerimage_{{$index}}" ng-model="mul.image" ngf-pattern="'image/*'" accept="image/*" ngf-max-size="2MB" ngf-min-height="400" ngf-resize="{width: 400, height:400}" ngf-select="onFileSelect1('upload_{{$index}}',mul.image);"> 
<div style="clear:both;"></div> 
</div> 
</div> 
<span class="input-group-btn" ng-show="mulImage.length>0"> 
<img ngf-thumbnail="mul.image" name="pro" border="0" style="width:32px; height:32px; border:#808080 1px solid;"> 
<input type="button" class="btn btn-success" name="plus" id="plus" value="+" ng-click="addNewImageRow(mulImage);" ng-show="$last"> <input type="button" class="btn btn-danger" name="minus" id="minus" value="-" ng-show="mulImage.length>1" ng-click="deleteNewImageRow(mulImage,$index);"> 

</span> 
<div class="help-block" ng-messages="billdata.upload_{{$index}}.$error" ng-if="billdata.upload_{{$index}}.$touched"> 
<p ng-message="maxSize" style="color:#F00;">File is too large.Max size is 2 mb.</p> 
<p ng-message="minHeight" style="color:#F00;">Minimum height should be 400px</p> 
</div> 
</div> 

hier, wenn ich das Hinzufügen dieser Validierungsnachricht <div class="help-block" ng-messages="billdata.upload_{{$index}}.$error" ng-if="billdata.upload_{{$index}}.$touched"> seine werfen die oben error.Please mir helfen, diesen Fehler zu beheben.

+0

Anweisungen in ng-if werden als Javascript behandelt, daher wird {{$ index}} nicht durch den Index ersetzt. – ayushgp

+0

Also, was sollte die Lösung sein. – satya

+0

Sie können die 'ng-if =" billdata.upload _ {{$ index}} ändern. $ Berührte "' zu 'ng-if =" billdata ['upload _' + this. $ Index]. $ Berührte "'. und dieselben Änderungen an ng-Nachrichten. – ayushgp

Antwort

0

Statt "billdata.upload_{{$index}}.$error, würde ich "billdata['upload_' + $index].$error

0

verwenden Sie die ng-if="billdata.upload_{{$index}}.$touched"-ng-if="billdata['upload_'+this.$index].$touched" ändern können. und die gleichen Änderungen an ng-messages

Verwandte Themen