What is wrong here?
function SecondCtrl($scope, Data) {
$scope.data = Data;
$scope.reversedMessage = function(message) {
return message.split("").reverse().join("");
};
}
What is wrong here?
function SecondCtrl($scope, Data) {
$scope.data = Data;
$scope.reversedMessage = function(message) {
return message.split("").reverse().join("");
};
}
As Arun mentioned in his comment, you're missing several key elements here:
You're not bootstrapping your app. You'll need to use either the ng-app directive or angular.bootstrap.
Since you're defining SecondCtrl as a global function (which isn't a best practice), you need to set JSFiddle to load your JavaScript before onLoad; I used No wrap - in <head>:

You're injecting Data into your controller, but you haven't defined Data as a service. You'll need to create a service for this.
Here's a JSFiddle that demonstrates how things might look if you follow best practices and create a module for your controller in addition to fixing the other issues: http://jsfiddle.net/BinaryMuse/TcPGT/
<div ng-app='myApp'>
<div ng-controller="SecondCtrl">
<input type="text" ng-model="data.message">
<h1>{{ reversedMessage(data.message) }}</h1>
</div>
</div>
var app = angular.module('myApp', []);
app.value('Data', {
message: 'This is my message.'
});
app.controller('SecondCtrl', function($scope, Data) {
$scope.data = Data;
$scope.reversedMessage = function(message) {
return message.split("").reverse().join("");
};
});
Your code i think is incomplete..Iam Attaching a complete code here..Go through it and i hope this is what your looking for.
Data