Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="pt-br">
<head>
	<meta charset="UTF-8">
	<title>Aprenda AngularJS - Formulário de Pedido</title>

	<link href="https://fonts.googleapis.com/css?family=Cookie|Open+Sans:400,700" rel="stylesheet">

	<!-- Arquivo CSS principal -->
	<link rel="stylesheet" href="style.css">

	<!--[if lt IE 9]>
		<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

</head>

<!-- Declare uma nova aplicação AngularJS e associe o controlador -->
<body ng-app ng-controller="OrderFormController">
	<form>
		
		<h1>Serviços</h1>
		
		<ul>
			<!-- Percorre o array 'services', atribuindo um manipulador click, e defini ou remove a classe css "active" se necessário -->
			<li ng-repeat="service in services" ng-click="toggleActive(service)" ng-class="{ active:service.active }">
			
				<!-- Note o uso do 'current filter', que vai formatar o preço -->
				{{ service.name }} <span>{{ service.price | currency: "R$ " }}</span>
			</li>
		</ul>

		<div class="total">
			<!-- Calcule o preço total de todas as escolhas de serviços. Formate isso como moeda -->
			Total: <span>{{ total() | currency:"R$ " }}</span>
		</div>

	</form>

	<!-- Include AngularJS from Google's CDN -->
	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
	<script src="script.js"></script>
</body>
</html>
              
            
!

CSS

              
                /*-------------------------
	Simples RESET
--------------------------*/


*{
	margin:0;
	padding:0;
}

/*-------------------------
	Estilos Gerais
--------------------------*/

body {
	font: 15px/1.3 'Open Sans', sans-serif;
	color: #5E5B64;
	text-align: center;
}

a, a:visited {
	outline: none;
	color: #389DC1;
}

a:hover {
	text-decoration: none;
}

section, footer, header, aside, nav {
	display: block;
}

/*-------------------------
	Formulário de Pedido
--------------------------*/

form {
	background-color: #61A1BC;
	border-radius: 2px;
	box-shadow: 0 1px 1px #CCC;
	width: 400px;
	padding: 35px 60px;
	margin: 80px auto; 
}

form h1 {
	color: #FFF;
	font-size: 64px;
	font-family: 'Cookie', cursive;
	font-weight: normal;
	line-height: 1;
	text-shadow: 0 3px 0 rgba(0,0,0,0.1);
}

form ul {
	list-style: none;
	color: #FFF;
	font-size: 20px;
	font-weight: bold;
	text-align: left;
	margin: 20px 0 15px;
}

form ul li {
	padding: 20px 30px;
	background-color: #E35885;
	margin-bottom: 8px;
	box-shadow: 0 1px 1px rgba(0,0,0,0.1);
	cursor: pointer;
}

form ul li span {
	float: right;
}

form ul li.active {
	background-color: #8EC16D;
}

div.total {
	border-top: 1px solid rgba(255, 255, 255, 0.5);
	padding: 15px 30px;
	font-size: 20px;
	font-weight: bold;
	text-align: left;
	color: #FFF;
}

div.total span {
	float:right;
}




              
            
!

JS

              
                function OrderFormController ($scope) {

	// Defina o modelo de propriedades. O View vai fazer o loop
	// através do array services e gerar um elemento li
	// para cada um dos itens.

	$scope.services = [
		{
			name: 'Desenvolvimento Web',
			price: 3000,
			active: true
		}, {
			name: 'Design',
			price: 2000,
			active: false
		}, {
			name: 'Integração',
			price: 2500,
			active: false
		}, {
			name: 'Treinamento',
			price: 2200,
			active: false
		}
	];

	$scope.toggleActive = function (s) {
		s.active = !s.active;	
	};

	// Método útil para calcular o preço total
	$scope.total = function () {

		var total = 0;

		// Uso o método auxiliar do Angular 'forEach'
		// para iterar o array services

		angular.forEach ($scope.services, function (s) {
			if (s.active) {
				total += s.price;
			}
		});

		return total;
	};

}
              
            
!
999px

Console