AngularJS: Difference between revisions
Jump to navigation
Jump to search
Line 48: | Line 48: | ||
console.log("Name: " + key + " Value: " + value); | console.log("Name: " + key + " Value: " + value); | ||
}); | }); | ||
</source> | |||
== Modules == | |||
<source lang="javascript"> | |||
var myApp = angular.module("myApp", []); // create the app | |||
var myApp = angular.module("myApp"); // gives an error if the app hasn't been created | |||
</source> | </source> |
Revision as of 17:43, 25 May 2015
Good tutorials:
Example
<!DOCTYPE html>
<html ng-app="exampleApp" >
<head>
<title>AngularJS Demo</title>
<link href="bootstrap.css" rel="stylesheet" />
<link href="bootstrap-theme.css" rel="stylesheet" />
<script src="angular.js"></script>
<script>
var myApp = angular.module("exampleApp", []);
myApp.controller("dayCtrl", function ($scope) {
// controller statements will go here
});
</script>
</head>
<body>
<div class="panel" ng-controller="dayCtrl">
<div class="page-header">
<h3>AngularJS App</h3>
</div>
<h4>Today is {{day || "(unknown)"}}</h4>
</div>
</body>
</html>
Utility methods
angular.isNumber(o);
angular.isString(o);
angular.isArray(o);
angular.isObject(o);
angular.lowercase(o);
angular.uppercase(o);
angular.extend(obj1, obj2); // add properties of obj2 to obj1
for (var prop in myData) {
console.log("Name: " + prop + " Value: " + myData[prop]);
}
angular.forEach(myData, function (value, key) {
console.log("Name: " + key + " Value: " + value);
});
Modules
var myApp = angular.module("myApp", []); // create the app
var myApp = angular.module("myApp"); // gives an error if the app hasn't been created