最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

angularJS 中input示例分享

 更新時(shí)間:2015年02月09日 09:52:00   投稿:hebedich  
這篇文章主要介紹了angularJS 中input示例分享,需要的朋友可以參考下

這里給大家分享一則input指令的使用示例

復(fù)制代碼 代碼如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無(wú)標(biāo)題文檔</title>
</head>
<script src="http://localhost:81/js/jquery.js">
</script>
<script src="http://localhost:81/js/angular.min.js">
</script>
<body ng-app="Demo">
<div ng-controller="TestCtrl">
    <input type="text" ng-model="a" test />
    <button ng-click="show(a)">查看</button>
</div>
</body>
<script>
   var app = angular.module('Demo', [], angular.noop);
   app.directive('test', function(){<br>   //input 指令的 link有第四個(gè)參數(shù),$ctrl有些方法,你可以自己拿來(lái)用
     var link = function($scope, $element, $attrs, $ctrl){
    console.log( $ctrl )
       $ctrl.$formatters.push(function(value){
         return value.join(',');
       });
       $ctrl.$parsers.push(function(value){
         return value.split(',');
       });
     }
     return {compile: function(){return link},
             require: 'ngModel',
             restrict: 'A'}
   });
   app.controller('TestCtrl', function($scope){
     $scope.a = [];
     //$scope.a = [1,2,3];
     $scope.show = function(v){
       console.log(v);
     }
   });
</script>
</html>

代碼很簡(jiǎn)單,小伙伴們自由擴(kuò)展下,希望大家能夠喜歡

相關(guān)文章

最新評(píng)論

丹巴县| 敦化市| 苍溪县| 西平县| 甘谷县| 台南市| 洛川县| 海安县| 富源县| 杭锦旗| 会同县| 维西| 普定县| 济源市| 漯河市| 中宁县| 曲沃县| 交口县| 翼城县| 武山县| 滨海县| 会泽县| 沈丘县| 邹平县| 全州县| 招远市| 鹰潭市| 霍山县| 洪泽县| 大化| 利川市| 广汉市| 太康县| 高邮市| 通海县| 闵行区| 天峻县| 璧山县| 宁城县| 牙克石市| 双江|