これが使用される入力命令のサンプルです
コードコピーは次のとおりです。
<!doctype html>
<html>
<head>
<メタcharset = "utf-8">
<title> un unt ittitled document </title>
</head>
<スクリプトsrc = "http:// localhost:81/js/jquery.js">
</script>
<スクリプトsrc = "http:// localhost:81/js/angular.min.js">
</script>
<body ng-app = "demo">
<div ng-controller = "testctrl">
<入力型= "text" ng-model = "a" test />
<ボタンng-click = "show(a)"> view </button>
</div>
</body>
<スクリプト>
var app = angular.module( 'demo'、[]、angular.noop);
app.directive( 'test'、function(){<br> //入力指令のリンクには4番目のパラメーターがあり、$ ctrlの方法がいくつかあり、自分で使用できます。
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}、
要求: 'ngmodel'、
制限: 'a'}
});
App.Controller( 'testctrl'、function($ scope){
$ scope.a = [];
//$SCOPE.A = [1,2,3];
$ scope.show = function(v){
console.log(v);
}
});
</script>
</html>
コードは非常にシンプルで、友達はそれを自由に拡張できます、私はあなたがそれを好きになることを願っています