0
有以下问题。我想提出两个指示。其中之一将成为另一个属性。 就是这样。作为另一个指令的属性表示的指令的链接和控制器功能不起作用
<html>
<title>Directives</title>
<head lang="en">
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js" type="text/javascript"></script>
<script src="main.js"></script>
</head>
<body ng-app="app">
<outer inner></outer>
</body>
</html>
该指令的源代码是在这里:
var app = angular.module('app', []);
app.directive('inner', function() {
return {
require: "^ngModel",
restrict: "AC",
transclude: true,
replace: false,
templateUrl: /* here is a path to template it's not interesting*/,
controller: function($scope) {
console.log('controller...');
},
link: function(scope, element, attrs) {
console.log('link...');
}
};
});
app.directive('outer', function($q, $rootScope) {
return {
require: "^ngModel",
restrict: "E",
replace: true,
scope: { /* isolated scope */ },
controller: function($scope) {},
templateUrl: /* path to template */,
link: function (scope, elem, attrs, ctrl) {}
}
});
的问题是外部的作品是控制器,但内心不...无论链接,也不控制器功能的工作原理...不能明白什么是错的...
任何想法?
该代码是不够的,我认为。运行这个我没有问题。尝试与一个笨重的代码放置足够的代码来让它破解。 –
确实是一个小提琴/笨拙的,但你也可以尝试没有'replace:true'? –
其实这就是我所拥有的......但这里的小提琴上的代码是相同的http://jsfiddle.net/vz5Tt/5/。也许它会有帮助... –