Last active
August 29, 2015 14:27
-
-
Save gabrielfeitosa/c7546a1e583ec83c49c4 to your computer and use it in GitHub Desktop.
Utilizando Services no AngularJS
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 ng-app="app"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Blog do Gabriel Feitosa</title> | |
</head> | |
<body> | |
<h1>Usando o service $window</h1> | |
<!--Declaração do controlador AlertController e definição do nome que será usado para utilização 'ctrl'--> | |
<div ng-controller="AlertController as ctrl"> | |
<fieldset> | |
<legend>Criador de alertas</legend> | |
<input ng-model="ctrl.alerta.mensagem" placeholder="Qual o mensagem de alerta?" /> | |
<br> | |
<button ng-click="ctrl.enviar()">Enviar</button> | |
</fieldset> | |
</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('AlertController', ['$window', function($window) { | |
var self = this; | |
self.alerta = { | |
mensagem: '' | |
}; | |
self.enviar = enviar; | |
function enviar() { | |
$window.alert('Mensagem criada : ' + self.alerta.mensagem); | |
} | |
}]); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment