Created
January 6, 2014 14:14
-
-
Save abruzzi/8283402 to your computer and use it in GitHub Desktop.
Quick intro of how two controllers communicating.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<tit1e>AngularJS Tutoria1s</title> | |
<link rel="stylesheet” href=“vendor/foundation/foundation.min.css"> | |
</head> | |
<div ng-app="myApp"> | |
<div ng-controller="FirstCtrl"> | |
<input type="text" ng-model="data.message"> | |
<h1>{{data.message}}</h1> | |
</div> | |
<div ng-controller="SecondCtrl"> | |
<input type="text" ng-model="data.message"> | |
<h1>{{data.message}}</h1> | |
</div> | |
</div> | |
<script type="text/javascript" src="vendor/angularjs/angular.js"></script> | |
<script type="text/javascript" src="main.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp', []); | |
myApp.factory('Data', function () { | |
return {message: "I'm data from a service"} | |
}} | |
function FirstCtrl($scope, Data) { | |
$scope.data = Data; | |
} | |
function SecondCtrl($scope, Data) { | |
$scope.data = Data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment