zoukankan      html  css  js  c++  java
  • Angulajs系列-01-入门

    1.解决什么问题?

    a, controller的各种的创建

    b,体验angular的双向绑定

    2.怎么解决

    2.1 引入angularjs

      下载地址

    2.2 创建controller的方法

    2.2.1 添加ng-app标识

    2.2.2 添加controller

    <div ng-controller="MyController">
              <p>Name:{{user.Name}}</p>
              <p>Age:{{user.Age}}</p>
          </div>

    2.2.3 直接创建

     // 直接创建
            function MyController($scope) {
                $scope.text = "234";
                $scope.user = {
                    Name: 'test',
                    Age: 18
                }
            }

    2.2.4 通过数组方式创建

      // 通过数组的方式进行创建
            var MyController = ['$scope', '$timeout', function ($scope, $timeout) {
                $scope.user = {
                    Name: 'test',
                    Age: 18
                };
                $timeout(function () {
                    alert('123');
                }, 1000);
            }];

    2.2.5 通过inject创建

     // 通过inject方式创建
            var MyController = function ($scope, $timeout) {
                $scope.user = {
                    Name: 'test',
                    Age: 18
                };
                $timeout(function () {
                    alert('123');
                }, 1000);
            };
            mycontroller.$inject = ['$scope', '$timeout'];

    3.源码下载

       https://git.oschina.net/yudaming/Angularjs

    4.广告时间 

      觉得还好的话,点个赞关注我哦。

  • 相关阅读:
    9-单表查询
    02-数据库概述
    01-MySql的前戏
    mysql+centos7+主从复制
    Mac下安装ipython与jupyter
    python开发之virtualenv与virtualenvwrapper讲解
    python操作redis
    权限管理具体代码实现
    docker入门
    多用判断&&
  • 原文地址:https://www.cnblogs.com/damsoft/p/6013884.html
Copyright © 2011-2022 走看看