AngularJS语法格式小结

    //创建一个最大的容器,"唯一的名字"   []数组
var a=angular.module("abcd",[]);
//控制器
a.controller("aactrl",function($scope,$http){
    //声明变量
    $scope.i="asdfsfdsfsadfdscasfdsacf";
    //匿名函数,scope分配一个独立的变量代表函数的名字
    $scope.aaa=function(){

    }

});
a.controller("actrl",function($scope,$http){
    $scope.tuser={
        un:"",
        up:""
    };
    $scope.usermsg={
        unmsg:"",
        upmsg:""
    };

    $scope.logshow=true;
    $scope.mainshow=false;

    $scope.cl=function(){
        if($scope.tuser.un==null||$scope.tuser.un==""){
            $scope.usermsg.unmsg="请输入用户名";
        }
        if($scope.tuser.up==null||$scope.tuser.up==""){
            $scope.usermsg.upmsg="请输入密码";
        }else{
            $scope.logshow=false;
            $scope.mainshow=true;
        }
    };

});
a.controller("bctrl",function($scope,$http){
    $scope.b=[];
    var f=$http.get("WebForm1.aspx");
    //获取数据成功data是从数据源获取的数据内容
    f.success(function(data){
        $scope.b=data;
    });
    f.error(function(){
    });
})

你可以使用 ng-bind 指令在你 UI 的任何地方显示和更新文本. 它有两种等价的形 式. 一种是我们见过的双花括号形式:
<p>{{greeting}}</p>
然后就是一个被称为 ng-bind 的基于属性的指令:
<p ng-bind="greeting"><p>
这两者的输出是等价的. 如果模型中的变量 greeting 设置为"Hi, there", Angular 将 生成这样的 HTML:

注意:

<html ng-app="myApp"> //ng-app写的是angular的名字,写在最大的标签html中
<body ng-controller="TextController">//ng-controller控制器写在那个标签证明控制那个标签内的内容

原文地址:https://www.cnblogs.com/yunqing/p/5801508.html