1
我正在使用Typeahead directive from the UI Bootstrap framework。我在另一个指令中使用这个指令。我的外部指令的定义是这样的:在子指令中获取范围值
.directive('myDirective', function() {
return {
restrict:'E',
transclude: true,
scope: {
showLinks: '=?',
query: '='
},
templateUrl: '/directives/my-directive.html',
controller: function ($scope) {
if (angular.isUndefined($scope.showLinks)) {
$scope.showLinks = true;
console.log('show links? ' + $scope.showLinks);
}
}
};
});
我-directive.html看起来是这样的:
<div style="width:100%;">
<span>{{showLinks}}</span> <!-- renders just fine -->
<input type="text" autofocus autocomplete="off" class="form-control" ng-model="query"
typeahead="option as option.Name for option in getLocation($viewValue)"
typeahead-min-length="3" typeahead-template-url="location.html" />
<script type="text/ng-template" id="location.html">
{{showLinks}} <!-- Never renders -->
<span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
</script>
</div>
我打电话给我的指示是这样的:
<my-directive show-links="true" />
我需要使用我用于打字的模板中的showLinks的值。不过由于某种原因,它并没有被传入模板中。我相信这与范围界定有关。如上所示,我通过将值绑定到UI来得出这个结论。 showLinks的值在我的模板中显示得很好。但是,它不会出现在我的指令中的typeahead实例的模板中。
我在做什么错?我觉得我很亲密。然而,我一直在努力。
感谢您提供任何帮助!
你是什么