Last active
August 29, 2015 14:27
-
-
Save gabrielfeitosa/252c6d55dd16737e98ea to your computer and use it in GitHub Desktop.
Entendendo os Controladores - Herança de $scope
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> | |
<!--Declaração do módulo da aplicação--> | |
<html ng-app="app"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Exemplo 3 - Blog do Gabriel Feitosa</title> | |
<style type="text/css"> | |
div.heranca div { | |
padding: 5px; | |
border: solid 2px #000; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Entendendo os Controladores - Herança de $scope</h1> | |
<!--Declaração do nosso MeuController--> | |
<div class="heranca"> | |
<div ng-controller="PaiController"> | |
<p>Eu sou {{nome}} {{sobrenome}}!</p> | |
<div ng-controller="FilhoController"> | |
<p>Eu sou {{nome}} {{sobrenome}}</p> | |
<div ng-controller="NetoController"> | |
<p>Eu sou {{nome}} {{sobrenome}}</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
<footer> | |
<hr/> | |
<a href="http://www.gabrielfeitosa.com"> Blog do Gabriel Feitosa</a> | |
</footer> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script> | |
<script> | |
var app = angular.module('app',[]); | |
app.controller('PaiController',['$scope',function($scope){ | |
$scope.nome = 'Gabriel'; | |
$scope.sobrenome='Feitosa'; | |
}]); | |
app.controller('FilhoController',['$scope',function($scope){ | |
$scope.nome = 'Lampião'; | |
}]); | |
app.controller('NetoController',['$scope',function($scope){ | |
$scope.sobrenome='Junior'; | |
}]); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment