I have 2 templates in ionic that have the same ng-controller. In the first template, I'm able to call {{answer}} that is declared in the function, but when I try to call it in the second template it doesn't show.
Here are the sample code:
1st. Template
<ion-view view-title="calculator" ng-controller="calcCtrl">
<input type="number" ng-model="num1">
<input type="number" ng-model="num2">
<button class="button button-block button-positive" ng-click="addition(num1, num2)">
Add
</button>
<h2>Answer: {{answer}}</h2>
2nd. Template
<ion-view view-title="Add" ng-controller="calcCtrl">
{{answer}}
</ion-view>
JS file:
app.controller("calcCtrl", function($scope) {
$scope.addition = function(num1, num2) {
$scope.answer = num1 + num2;
}
});
How can I call the output for {{answer}} in my 2nd. template?
answer.