日期:2014-05-16 浏览次数:20399 次
<!doctype html> <html ng-app> <head> <script src="http://code.angularjs.org/angular-1.0.1.min.js"></script> </head> <body> Hello {{'World'}}! </body> </html>
1+2 = {{1+2}}! #页面会显示 1+2 = 3!
<div ng-init="students = [ {name:'John', age:25, gender:'boy'}, {name:'Joy', age:15, gender:'girl'}, {name:'Mary', age:28, gender:'girl'}, {name:'Sebastian', age:10, gender:'boy'}, {name:'Samantha', age:16, gender:'girl'} ]"> <div data-ng-repeat="student in students"> <h3>{{student.name}}:{{student.age}}</h3> </div> </div>
<div data-ng-repeat="student in students" data-ng-show="student.gender=='boy'"> <h3>{{student.name}}:{{student.age}}</h3> </div>
<div data-ng-repeat="student in students" data-ng-show="student.gender=='boy'" data-ng-switch="student.age >18"> <h3>{{student.name}}:{{student.age}}</h3> <p data-ng-switch-when="true">ADULT</p> </div>
<div data-ng-repeat="student in students"> <h3>{{student.name}}:{{student.age}}</h3> Edit Name: <input type="text" data-ng-model="student.name"> </div>
<div data-ng-repeat="student in students"> <h3>{{student.name|uppercase}}:{{student.age}}</h3> </div>
<html ng-app=“AngularJSSample”>
var AngularJSSample = angular.module('AngularJSSample', []);
var AngularJSSample = angular.module('AngularJSSample', []); AngularJSSample.filter('greet', function() { return function(name) { return 'Hello, ' + name + '!'; }; });
AngularJSSample.config(['$routeProvider', function($routeProvider){ }]) ;