Angular.js 初体验

html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>title>
    <link rel="stylesheet" href="css/index.css"/>
    <script src="js/angular.js">script>
head>
<body>
<header>
    <nav>
        <ul>
            <li id="ul1">星期一li>
            <li>星期二li>
            <li>星期三li>
            <li>星期四li>
            <li>星期五li>
        ul>
    nav>
header>
<div>
    <textarea rows="15" cols="5">
            111111111111111111111
    textarea>
div>
<a target="_blank">a>
<div  ng-app="myApp">
    <div ng-controller="MyController">
        <h1>hello {{clock}}h1>
        <h1>hello {{name}}h1>
    div>
    <h1>hello {{name}}h1>

    <div ng-controller="firstController">
        <h4>the simple addding machine everh4>
            <button ng-click="add(1)" class="button">Addbutton>
            <a ng-click="subtract(1)" class="button alert"> Substracta>
        <h4> Current count:  {{counter}}h4>
    div>

    <div ng-controller="parentController">
        <div ng-controller="ChildController">
            <button ng-click="sayHello()">Say Hellobutton>
        div>
        {{person}}
    div>
    
    {{[{
        'name' : 'zhb',
        "city" : 'cd',
        'food' : "rice"
    },{
    'name' : "wll",
    "city" : "yibin",
    "food" : "milk"
     }] | filter : {'name': "wll"}
    }}

    <div ng-show="showLoginFrom">
        <from ng-submit="runLogin()">from>
    div>
    <div ng-show="!showLoginFrom">
        <from ng-submit="runRegister()">from>
    div>
div>
<script src="js/APP1.js">script>
body>
html>

/**
 * Created by Administrator on 2016/1/5.
 */
var myApp = angular.module('myApp', []);
myApp.controller("MyController", function($scope, $timeout){
    var updateClock = function() {
        $scope.name = 'zhengbiao';
        $scope.clock = new  Date();
        $timeout(function() {
            updateClock();
        }, 1000);
    };
    updateClock();
});
myApp.run(function($rootScope) {
    $rootScope.name = 'world';
});
myApp.controller('firstController', function($scope) {
    $scope.counter = 0;
    $scope.add = function(amount) {
        $scope.counter += amount;
    }
    $scope.subtract = function(amount) {
        $scope.counter -= amount;
    }
});
myApp.controller('parentController', function($scope) {
   $scope.person = {
       greeted : false
   };
});
myApp.controller('ChildController', function($scope) {
    $scope.sayHello = function() {
        $scope.person.name = 'zhengbiao nihao';
    };
});
myApp.controller('LoginController', function($scope) {
    $scope.showLoginFrom = true;
    $scope.sendLogin = function() {};
    $scope.sendRegister = function() {};
});



你可能感兴趣的:(前端,Angular.js,体验)