Angularjs 开始之Hello world
生活随笔
收集整理的這篇文章主要介紹了
Angularjs 开始之Hello world
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
為什么這樣寫
像所有程序的開始一樣,使用 angularjs 也從 Hello world 開始
書寫 Html 結構
<html> <head><title>學習 Angularjs1.x</title> </head> <body ng-app="MyApplication"><script src="http://apps.bdimg.com/libs/angular.js/1.5.0-beta.0/angular.min.js"></script><script type="text/javascript">// 這里是 JS 代碼</script> </body> </html>輸出一個 Hello world
<html ng-app="MyApplication"> <head><title>學習 Angularjs1.x</title> </head> <body ng-controller="HelloWorld"><div ng-bind="text"></div><script src="http://apps.bdimg.com/libs/angular.js/1.5.0-beta.0/angular.min.js"></script><script type="text/javascript">// 這里是 JS 代碼angular.module('MyApplication', []).controller('HelloWorld', ['$scope', function($scope){$scope.text = "Hello world";}]);</script> </body> </html>復制以上 DEMO 到自己的 HTML 文件中,運行即可。
關于如何運行自己的程序,請看那些WEB服務器們
總結
以上是生活随笔為你收集整理的Angularjs 开始之Hello world的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 初识 Angularjs1.x ,了解5
- 下一篇: 常用的 WEB 服务器