Angularjs 中的 controller

來源:互聯網
上載者:User

標籤:++   lines   tty   rect   rac   nes   com   angular   scope   

接觸過程式開發的小夥伴們對 MVC 的開發方式想必一點也不陌生,是的, angularjs 所採用的方式便是 MVVM 的開發方式,這裡的 controller 即控制器

瞭解 controller

The ngController directive attaches a controller class to the view. This is a key aspect of how angular supports the principles behind the Model-View-Controller design pattern.

譯文:

ngController 是關注於視圖 controller 的一個指令

指令的基本資料
This directive creates new scope.This directive executes at priority level 500.

譯文:

指令會建立一個 scope 即範圍
什麼時候使用 controller

當我們須要一個新的模組而且不希望它跟其它模組的資料產生衝突的情況下。我們就能夠使用一個 ngController 來獨立這一塊的內容,比方我們的文章本文模組能夠使用 ng-controller=”AricleController”。而文章中的評論模組則能夠使用 ng-controller=”CommentController” 來完畢

Angularjs 中的 controller

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.