练习1:{{greeting.text}}会根据input的值而改变
<!doctype html> <html lang="en" ng-app> <head> <meta charset="utf-8"> <title>Angular</title> </head> <body> <input type="text" ng-model = "greeting.text" /> <p>{{greeting.text}},angular</p> <script src="/bower_components/angular/angular.min.js" type="text/javascript" charset="utf-8"></script> </body> </html>
练习2:页面输出 Hi everyone!
<!doctype html> <html lang="en" ng-app = "MyModule"> <head> <meta charset="utf-8"> <title>Angular</title> </head> <body> <hello></hello> <script src="/bower_components/angular/angular.min.js" type="text/javascript" charset="utf-8"></script> <script> var myModule = angular.module("MyModule", []); myModule.directive("hello", function() { return { restrict: ‘E‘, template: ‘<div>Hi everyone!</div>‘, replace: true } }); </script> </body> </html>
时间: 2024-10-12 07:09:45