<!DOCTYPE html> <html> <head> <Meta charset="utf-8"> </head> <body> <div ng-app=""> <p>名字 : <input type="text" ng-model="name"></p> <h1>Hello {{name}}</h1> </div> </body> <script src="angular.min.js"></script> </html>
<!DOCTYPE html> <html> <head> <Meta charset="utf-8"> </head> <body> <div ng-app="" ng-init="firstName='hehongbo'"> <p>姓名是:<span ng-bind="firstName"></span></p> </div> </body> <script src="angular.min.js"></script> </html>
AngularJS表达式:
<!DOCTYPE html> <html> <head> <Meta charset="utf-8"> <title>AngularJS表达式</title> </head> <body> <div ng-app=""> <p>AngularJS表达式:{{5 + 5}}</p> </div> </body> <script src="angular.min.js"></script> </html>
AngularJS 应用:
<!DOCTYPE html> <html> <head> <Meta charset="utf-8"> <title>AngularJS表达式</title> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> 名: <input type="text" ng-model="firstName"><br> 姓: <input type="text" ng-model="lastName"><br> <br> 姓名: {{firstName + " " + lastName}} </div> <script src="angular.min.js"></script> <script> var app = angular.module('myApp',[]); app.controller('myCtrl',function($scope) { $scope.firstName= "John"; $scope.lastName= "Doe"; }); </script> </body> </html>原文链接:https://www.f2er.com/angularjs/149193.html