gpt4 book ai didi

javascript - AngularJS:将 ng-transclude 放入变量(ng-transclude 到占位符)

转载 作者:行者123 更新时间:2023-11-29 15:25:40 24 4
gpt4 key购买 nike

我有一个带有嵌入文本的指令,我需要将它放在占位符中

我的html

 <div ng-controller="Controller">
<my-dialog>Hello world!</my-dialog>
</div>

JS

(function(angular) {
'use strict';
angular.module('docsTransclusionDirective', [])
.controller('Controller', ['$scope', function($scope,$transclude) {
console.log($transclude);
$scope.name = $transclude; // I NEED TO GET HELLO WORLD HERE

}])
.directive('myDialog', function() {
return {
restrict: 'E',
transclude: true,
scope: {},
templateUrl: 'my-dialog.html'
};
});
})(window.angular);\

我的模板

<div>this should give me transcluded text {{name}}</div>

最佳答案

获取嵌入内容的方法有多种。 Have a look at this question

关于javascript - AngularJS:将 ng-transclude 放入变量(ng-transclude 到占位符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39407291/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com