Here is the code snippet I am currently working with:
var app = angular.module('app', []);
var appCtrl = app.controller('AppCtrl', AppCtrl);
function AppCtrl(){
var appCtrl = this;
appCtrl.variable = "search";
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app = "app">
<div ng-controller = "AppCtrl as ctrl1">
{{ctrl1.variable}}
</div>
<div ng-controller = "AppCtrl as ctrl2">
<input type="search" ng-model = "ctrl2.variable"/>
{{ctrl2.variable}}
</div>
</div>
After updating ctrl2.variable
, the value of ctrl1.variable
remains unchanged.
Is there a way to update it without resorting to using $scope
?