Last active
August 29, 2015 14:00
-
-
Save fernandozamoraj/df68eeb6f615f5ff1004 to your computer and use it in GitHub Desktop.
Simplest Example of angular.js
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="myApp"> | |
<head> | |
<title>Simple Example of Angular.js</title> | |
</head> | |
<body> | |
<h1>Events</h1> | |
<div ng-controller="eventController"> | |
<div ng-repeat="event in events"> | |
<br/>{{event.date}} | |
<br/>{{event.name}} | |
<br/>{{event.location}} | |
</div> | |
</div> | |
<h1>Members</h1> | |
<div ng-controller="memberController"> | |
<div ng-repeat="member in members"> | |
<br/>{{member.name.first}} {{member.name.last}} | |
<br/>{{member.joinedDate}} | |
</div> | |
</div> | |
<!--assuming you have a directory named scripts and the angular.min.js file in it--> | |
<script src="scripts/angular.min.js"></script> | |
<script> | |
var myApp = angular.module("myApp", []); | |
myApp.controller('eventController', function eventController($scope){ | |
$scope.events = [ | |
{name: "JS Hackathon", location: "Salado", date: "1 June 2014"}, | |
{name: "Java User Group", location: "Austin Capitol Factory", date: "10 June 2014"}, | |
{name: "ADNUG", location: "Austin MS Office", date: "1 July 2014"}, | |
{name: "C# UG", location: "Temple MAT Campus", date: "3 Aug 2014"} | |
]; | |
}); | |
myApp.controller('memberController', function memberController($scope){ | |
$scope.members = [ | |
{name: {first: "John", last: "Doe"}, joinedDate: "21 Dec 2012"}, | |
{name: {first: "Jane", last: "Smith"}, joinedDate: "6 June 1944"}, | |
{name: {first: "Ike", last: "Turner"}, joinedDate: "25 Dec 2013"} | |
]; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment