AngularJS的基礎元素應用

來源:互聯網
上載者:User

標籤:bin   oct   綁定   option   目標   處理   phone   ndt   control   

<!doctype html><!-- 標記ng-app告訴AngularJS處理整個HTML頁並引導應用 --><html ng-app>    <head>        <meta charset="UTF-8">        <script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>        <script src="js/controllers.js"></script>        <!-- 當綁定兩個花括弧在title元素上可以實現我們的目標,但是你或許發現了,頁面正載入的時候它們已經顯示給使用者看了。一個更好的解決方案是使用ngBind或者ngBindTemplate指令,它們在頁面載入時對使用者是不可見的 -->        <title ng-bind-template="Google Phone Gallery: {{‘ha ha‘}}">Google Phone Gallery</title>    </head>    <body ng-controller="PhoneListCtrl">        <!-- 雙向繫結 ng-model="yourname" -->        Your name: <input type="text" ng-model="yourname" placeholder="World">        <hr>        Hello {{yourname || ‘World‘}}!        <hr>        <!-- 從控制器取出資料,迭代顯示 -->        <!-- PhoneListCtrl控制器裡面的方法 -->        Search: <input ng-model="query">        <!-- 這裡的 orderProp會取出控制器裡面的預設 orderProp="age" -->        Sort by:        <select ng-model="orderProp">          <option value="name">name order</option>          <option value="age">age order</option>        </select>        <ul>            <!-- 控制器中 PhoneListCtrl方法定義的變數 phones迭代   ng-repeat迭代元素-->            <!-- filter函數使用query的值來建立一個只包含匹配query記錄的新數組 -->            <!-- orderBy排序綁定到上面的 orderProp元素 -->            <li ng-repeat="phone in phones | filter:query | orderBy:orderProp">                {{phone.name}}                <p>{{phone.snippet}}</p>            </li>            <hr>            <!-- 下面是一些聯絡 -->            <p>Total number of phones: {{phones.length}}</p>        </ul>        <hr>        <div ng-controller="HelloWordCtrl">            測試控制器: {{hello}}        </div>        <hr>        <table>            <tr><th>row number</th></tr>            <tr ng-repeat="i in [0, 1, 2, 3, 4, 5, 6, 7]"><td>{{i}}</td></tr>        </table>    </body></html>

 

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.