Hi,
I’m sarting with Ionic and i’m French, so, if i’m not clear, don’t hesitate to tell me !
I have a view which i can add an user in my app. Very basic, it contains only first name and last name inputs. By habit, when i do a simple view like this, i manage to use the same view for the edit purpose. To do that here, i try to add a var in my $scope, and, in my templates, with a ternary, i put what i want according to this variable. Problem ; i can’t access to this var…
The buttons add and edit are in the view “peoples” and the form view is named ‘addpeople’ , but the two views have the same controller.
Here is my code
When i add a user , i call the openadd function
$scope.openadd = function() {
$scope.formadduser = { first: '', last : '' };
$scope.test = 0; $state.go('addpeople');
};
When i edit a user :
$scope.editadd = function() {
$scope.test = 1;
$state.go('addpeople');
};
And, in my view :
<ion-view view-title="{{test && 'class-when-true' || 'class-when-false' }}">
But the “test” value, when i print it, is blanck…I suppose this is because i change the view, but I’m still in the same controller, yet…
Can you tell me what is wrong, and if there is a cleaner way to reach my goal ?
Thanks