-3
컨트롤러 및 지시문을 app.js에 정의하고 index.html에서 사용합니다.범위 변수를 사용하여 컨트롤러에서 지시문으로 값을 가져 오는 방법
는 "세계"를 인쇄해야 내 지시에
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
app.directive('search', function() {
return {
scope: {
display: '='
},
restrict: 'AE',
replace: true,
link: function(scope, elm, attrs) {
alert(display);
}
};
});
index.html을 내가 경고 (표시)를 제공
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="[email protected]" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js" data-semver="1.2.17"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<search display="name"></search>
</body>
</html>
에게 app.js.
그 시도했지만 난 당신이 – user3824049
정의되지 않은 방법 : 오류 : [$ 컴파일 : tpload가] 템플릿을로드하지 못했습니다 : template.html. 확대되지 않은 버전의 각도를로드하면 오류 메시지가 더 적합 해집니다. – pixelbits
오류는 문제 보여주는 plunker 만들 것을 제안 – pixelbits