반응형
src 변수를 사용한ng-module
ng-includes src를 변수로 변경하고 싶습니다.현재 제가 가지고 있는 것은 이것입니다.
<div class='alignRightCenter' id='rightContent'>
<ng-include src="'{{view}}'"> </ng-include>
</div>
컨트롤러는 다음과 같습니다.
ctrl.controller('contentCtrl', ['$scope', function($scope) {
$scope.view = "partials/setListName.tpl.html";
}]);
유감스럽게도 ng-view는 이미 이 페이지로 이동하기 위해 사용되고 있기 때문에 사용할 수 없습니다.이런 일을 할 수 있을까요?
다음과 같이 시도합니다.
<ng-include src="view"> </ng-include>
---------------------------------------------
이렇게 하면 돼요.
표시:
<div data-ng-include data-ng-src="getPartial()"></div>
컨트롤러:
function AppCtrl ($scope) {
$scope.getPartial = function () {
return 'partials/issues.html';
}
}
이것처럼.JavaScript에서처럼 작은 따옴표와 +를 사용해야 합니다.
<ng-include src="'/path/to/template'+ my.variable +'.html'"></ng-include>
언급URL : https://stackoverflow.com/questions/21860225/ng-include-with-a-variable-for-src
반응형
'programing' 카테고리의 다른 글
Angular를 사용하여 새 창에서 링크 열기JS (0) | 2023.03.28 |
---|---|
지시문 삽입(프로그래밍 각도)JS (0) | 2023.03.28 |
MacOS의 VS 코드에서 Python 스크립트를 시작할 때 "SyntaxError: invalid 구문"이 표시됩니다. (0) | 2023.03.28 |
SVG를 Next.js로 가져올 수 없습니다. (0) | 2023.03.28 |
IIS6에서 JSON 파일(POST, GET 등)을 처리하도록 합니까? (0) | 2023.03.23 |