AngularJS注意的一些小點

來源:互聯網
上載者:User

標籤:決定   app   strong   span   text   tle   utf-8   mod   cti   

本人剛剛接觸AngularJS,還不太熟悉,就說說我目前遇到的一些注意點吧。

  1、調用外來檔案script檔案

MVC設計模式

html檔案

<!DOCTYPE html>
<html >
  <head>
  <meta charset="UTF-8">
  <title></title>
  </head>
  <body>

    //ng  表示 angular ,ng-app放在這一行的div上,就決定與Angular指令碼放哪裡,表示作用於只在這一行內的div有效;ng-controller 表示控制器;greeting.text 表示 module參數

    //注意: 調外來檔案的時候,ng-app 不需要帶參數,如:ng-app="myAPP"
    <div ng-app ng-controller="HelloAngular"> 
      <p>{{greeting.text}},Angular</p>
    </div>
    <script type="text/javascript" src="js/angular.min.js" ></script>//angularJs的封裝好的檔案
    <script type="text/javascript" src="js/angular.js" ></script>//自己寫的script外來檔案
  </body>
</html>

scrript檔案

//不需要(function(){運算式})();只需要一個函數 function  HelloAngular(ng-controller的參數){運算式}

function HelloAngular($scope){
  $scope.greeting = {
    text : ‘hello‘
  };
}

AngularJS注意的一些小點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.