Angularjs[12] - 模組

來源:互聯網
上載者:User

標籤:依賴   end   utf-8   關係   conf   doc   angular   name   javascrip   

模組是組織業務的一個框,在一個模組中定義多個服務,當引入一個模組的時候,就可以使用這個模組的一種或多種服務。Angular js 本身的一個預設模組叫做ng,它提供了 $http, $scope 等服務。服務只是模組提供的多種機制中的一種,其他的還有指令(directive),過濾器(filter)及其他配置資訊。可以在已有的模組中新定義一個服務,也可以先新定義一個模組,然後在新模組中定義新服務。服務需要顯式的聲明依賴(引入)關係,讓ng自動做注入。

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title></title></head><body>    <div ng-app="myApp">        <div ng-controller="firstController">            {{name}}        </div>    </div><script type="text/javascript" src="../../vendor/angular/angularjs.js"></script><script type="text/javascript" src="app/index.js"></script></body></html>
var myApp = angular.module(‘myApp‘,[]);myApp.controller(‘firstController‘,function ($scope) {    $scope.name = ‘Alrale‘});
  • angular.module(name,[requires],configFn)

     configFn: 會在模組初始化時執行,可以在裡面配置模組的服務。

 

Angularjs[12] - 模組

聯繫我們

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