angular基础(一)

–*指令 end

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<script src="angular.min.js"></script>
<style>
    .custom-html{color:red;}
</style>
</head>
<body>

<div ng-app="myApp" ng-controller="myCtrl" ng-init="cost=5;num=4;address={province:'shenzhen',detail:'nanshan'};age=[25,26,27]">
    姓:<input type="text" ng-model="firstName"><br>
    名:<input type="text" ng-model="lastName"><br>
    全名:{{firstName + ' ' + lastName}}<br>
    <ul ng-repeat="value in age">
        {{value}}岁?
    </ul>
    年龄:{{age[2]}} <br>
    4*5 = {{cost * num}} <br>
    居住地:{{address.province+' '+address.detail}} <br>
    <ul ng-repeat="value in country">
        {{value.name}} : {{value.num}}枚金牌
    </ul>
    <custom-html></custom-html> <!-- E -->
    <div custom-html></div> <!-- A -->
    <div class="custom-html"></div> <!-- C -->
    <!-- M  replace:true -->
    <!-- directive: custom-html -->
</div>

<script>
    var app = angular.module('myApp',[]); //demo中ng-app为‘myApp’元素是angular应用程序
    app.controller('myCtrl',function($scope){ //myApp应用程序是由什么数据内容控制的
        $scope.firstName = "SUN";
        $scope.lastName = "GANG";
        $scope.country = [
            {num:25,name:'中国'},
            {num:3,name:'USA'},
            {num:0,name:'JP'},
        ]
    });

    app.directive("customHtml",function(){
        return {
            restrict : "AECM",
            replace : true,
            template:"<h3>directive用于自定义标签内容!</h3>"
        }
    })
</script>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值