angularjs - ng-form nested within ng-switch -
i ran issue ng-form not setting form on scope when nested within ng-scope.
for example
<div ng-controller='testctrl'> <ng-switch on="switchme"> <div ng-switch-default>loading...</div> <div ng-switch-when="true"> <form name="nixtest"> <input placeholder='in switch' ng-model='dummy'></input> <button ng-click="test()">submit</button> </form> </div> </ng-switch> </div>
controller:
controllers.testctrl = function ($scope) { $scope.switchme = true; $scope.test = function () { if ($scope.nixtest) { alert('nixtest exists') } else { alert('nixtest dne') } } }
are there work arounds ? test fiddle can found here
ng-switch creates child scope , form created on scope. hence child scope form not available on parent scope.
to access it, can pass method test()
ng-click=test(nixtest)
. scope method signature need updated support input parameter.
Comments
Post a Comment