2016.10.24 anjularjs初步1

来源:互联网 发布:智乐软件 编辑:程序博客网 时间:2024/06/08 09:51

指令: ng-app : 定义angularJS应用的根元素。 <body class="container" ng-app="angularJSApp">。ng-init : 在应用程序运行前执行(初始化数据)字符串,数值,对象,数组。ng-bind : 数据初始化好以后,就可以绑定来用。ng-modal:实现双向绑定,ng-repeat: 遍历所有的集合,ng-controller:定义控制器。表达式: 写法:{{ expression }}。 ng-bind 同理,输出数据。 title by expr: {{info.title}} title: <span ng-bind="info.title"></span> 。控制器:在js中直接写函数  var app = angular.module('angularJSApp',[]); app.controller('myCtrl',function($scope){    $scope.name='angular';    $scope.info={title:'angularJS',price:130}; });。1.ng-controller="myCtrl" 定义了一个控制器。定义好的控制器 即 “myCtrl” 实际上是一个函数,一个普通的function。在 function中处理数据。即model 2. $scope: : 使用$scope对象调用控制器。用来保存angularJS model 。依赖注入 控制器参数: $scope: 1.在 HTML 和 JS 之间进行传递数据 2.只能在控制器的作用域内起作用 $element: angular内置的对象。 1. 是一个jQuery对象 2. 是作用域控制器所在的HTML元素

获取到html以后就可以根据需求去控制页面的样式,等等 $http: $http.get(url).success(function(result){}); 。模版包含: ng-include : 节点控制: ng-style: 控制节点的两种形式: 1.通过ng-style指令 <div ng-style="{width:200,height:200,background:'red'}"></div> 2.通过控制器 $scope.style={width:200,height:200,background:'red'};

ng-class: 添加执行类。显示/隐藏 ng-show: ng-hide:。   var nowDate = new Date();console.log(nowDate)//年月日 具体时间都有 console.log(nowDate.getDate())//日

  $scope.today = nowDate.getDay();//0-6 0--星期天   console.log(nowDate.getDay())

0 0
原创粉丝点击