index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="angular.js"></script>
<script src="input.js"></script>
</head>
<body ng-app="demo">
<myinput></myinput>
</body>
</html>
input.html
<div>
<input class="search-input" type="text" placeholder="搜索" ng-model="searchTxt" >
<button ng-click="click()" type="button">Click Me!</button>
</div>
input.js
angular.module("demo",[]);
angular.module("demo")
.directive('myinput',
function( ) {
return {
restrict: 'AE',
templateUrl: 'input.html',
// scope: {},
// replace: true,
link: function ($scope) {
$scope.click= function () {
var jj =0;
var xx = $scope.searchTxt
}
}
}
}
);