Here is a sample configuration:
var myApp = angular.module('myApp', []);
myApp.factory('Data', function () {
return { message: "I am data from a service" };
});
function FirstCtrl($scope, Data) {
$scope.data = Data;
}
function SecondCtrl($scope, Data) {
$scope.data = Data;
}
Although the hardcoded Data.message works fine, I am looking for a way to pass a value to the Data.message directly through the template without the need for additional http requests. Is there a way to achieve this?