Thursday, 15 March 2012

javascript - $scope.form contains field names but not values -



javascript - $scope.form contains field names but not values -

i cannot @ form value through $scope.form. in view , batarang see form object has right name fields, no values. on other hand, value in actual form field correct, $scope.mymodel.headline value (see illustration below).

why happen?

sample 1 field follows. batarang output:

{ mymodel: { headline: value } form: { mymodel[headline]: { } } }

if output {{form}} in view shows:

mymodel[headline]: { }

controller code simple:

@mymodelctrl = ['$scope', ($scope) -> $scope.init = (mymodel) -> $scope.mymodel = mymodel ]

much simplified html:

<div id="new_mymodel" ng-controller="mymodelctrl" ng-init="init({'headline': 'my value'})" class="ng-scope"> <form action="/myurl" id="new_mymodel" method="post" name="form" role="form"> <input id="mymodel_headline" name="mymodel[headline]" ng-model="mymodel.headline" ng-required="true" type="text"> <input type="submit"> </form> </div>

update: @ first thought accepted reply wrong, because of side issue. correct: issue developer console , batarang , view displaying wrong, not field empty. needed utilize $scope.form["mymodel[headline]"].$formvaue.

you can it's value

$scope.form['mymodel[headline]'].$modelvalue

see this.

javascript html5 angularjs batarang

No comments:

Post a Comment