I have a unique scenario in my application where I need to pass input from one view to another. I have set up a service as shown below:
.service('greeting', function Greeting() {
var greeting = this;
greeting.message = 'Default';
})
.controller('LogonController', function LogonController(greeting) {
var first = this;
first.greeting = greeting;
})
.controller('VideoController', function VideoController(greeting) {
var second = this;
second.greeting = greeting;
});
Here are my two distinct views using different controllers:
<div ng-controller="LogonController as first">
<form>
<input type="text" data-ng-model="first.greeting.message" placeholder="{{ first.greeting.message }}"> //1ST VIEW
</form>
</div>
<div ng-controller="VideoController as second">
<h1>{{ second.greeting.message }}</h1>
<div> //2ND VIEW
In the 1st form view, I want the placeholder to display the Default message even before any input is entered.
How can I achieve this functionality?