angular.js基础学习

1 MVC思想,M->module, V->view,C->control.

前后台各司其职。

2 angular的特点

以数据为中心,讲数据精确到类型。

操作数据,数据双向绑定,使用的数据和设置数据的位置是互通的

angular下的数据是不能重复的。

依赖注入, 把函数中的参数固定写死。位置是不固定的。

3 angular中的this指向问题

首先JS中的this指向 可以用 call 和 apply.

而在angular中 用 angular.bind

4 angular.forEach(arr,function(val,index){})------>循环(数组/json)。

//---------指令

5 ng-repeat----------->循环

	ng-repeat="name in arr"

6 ng-app 开启页面的angular模式。

7 ng-init 数据初始化 ng-init="a=12"

8 ng-model 创造数据  只能在 input 中使用

<inputtype="text"ng-model="a"/>{{a}}

9ng-bind 展示部分.

10 ng-show/hide. ng-show--->默认属性是hide.

11 ng-click等等 事件都可以

12 控制器

var app=angular.module('app',[]);

app.controller('aaa',function($scope){})

12 自定义过滤器

app.filter('name',function(){})

13 自定义指令

app.directive('name',function(){});

14 

配置路由:
   1. 引入js文件
      <script src="js/angular-route.js"></script>

   2. 设置配置:
      //配置路由
      app.config(function($routeProvider){
         $routeProvider.when('/index',{
            templateUrl:'a_1.html'
         }).when('/about',{
            templateUrl:'a_2.html' 
         }).otherwise({
            redirectTo:'/index'
         });    
      });
15 
   引入外部模板:
  	 <header ng-include="'2.html'"></header>
   	ng-include src="'header.html'"
   引入本页面模板  
	<script type="text/ng-template" id="demo">
  	 <h3>这是h3</h3>
	</script>
 	<header ng-include="'demo'"></header>
16 数据交互
$http
    可以get() post()   jsonp()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值