yassin
February 13, 2014, 6:55pm
1
Since I use the tag content, I am unable to access my model from my controller.
And this happens to me when I use this tag.
Partial:
<content has-header="true">
<form ng-submit="submit();">
<div class="list list-inset">
<label class="item item-input">
<input type="tel" placeholder="Phone number" ng-model="phone">
</label>
<br>
<input id="submit" type="submit" class="button button-block button-positive" value="Let's Go">
</div>
</form>
</content>
Controller ( submit function returns undefined ):
piltControllers.controller('SignInCtrl', ['$scope', '$http',
function($scope, $http) {
$scope.submit = function(){
alert($scope.phone);
}
}]);
Because Ionic directives frequently have isolate scopes, you might need to do this:
<form name="$parent.userForm" ng-submit="submit();">
<content has-header="true">
<form name="$parent.userForm" ng-submit="submit();">
<div class="list list-inset">
<label class="item item-input">
<input type="tel" placeholder="Phone number" ng-model="phone">
</label>
<br>
<input id="submit" type="submit" class="button button-block button-positive" value="Let's Go">
</div>
</form>
</content>
yassin
February 14, 2014, 5:23pm
3
Thank you very much but it doesn’t work
You’ll need to setup a small sample on CodePen or something so we can take a look.
yassin
February 16, 2014, 11:17am
5
Thanks, I solved my problem by specifying the controller for the form. But it must be depreciated? (The view is already linked to a controller by the router).
<content has-header="true">
<form ng-controller="SignInCtrl" ng-submit="submit();">
<div class="list list-inset">
<label class="item item-input">
<input type="tel" placeholder="Phone number" ng-model="phone">
</label>
<br>
<input id="submit" type="submit" class="button button-block button-positive" value="Let's Go">
</div>
</form>
</content>