AngularJs ng-include는 $scope로 전달되지 않는 한 뷰를 포함하지 않습니다.
라고 가정하는 것이 잘못된가?ngInclude길을 걸을 수 있을까?계속 세팅하려고 하는데ngInclude다음과 같습니다.
<div ng-include src="views/header.html"></div>
이거 안 되는데 이렇게 하면 돼요.
// HeaderController
app.controller('HeaderCtrl', function($scope){
$scope.templates = {[
template: { url: 'views/header.html' }
]};
$scope.template = $scope.templates[0].template;
});
my index.html에서
<div ng-controller="HeaderCtrl">
<div ng-include src="template.url"></div>
</div>
한다ngInclude범위 밖의 값만 제외합니까?그렇다면 html partial을 직접 포함시키지 않고 왜 이런 방식일까요?
ng-include 는 식을 받아들입니다.여기서 직접 명시적인 URL을 지정할 경우 문자열을 지정해야 합니다.
<div ng-include src="'page.html'"></div>
다른 지시사항(,ng-class ...)과 마찬가지로 스코프에서 각도 식을 평가합니다ng-include.따옴표 없음('')는 스코프의 변수를 검색합니다.
다음 명령어를 지정할 필요는 없습니다.src기여하다.
<div ng-include src="'views/header.html'"></div>
다시 쓸 수 있는 위치: (그것이 더 간단함)
<div ng-include="'views/header.html'"></div>
ng-include를 요소로 사용할 수도 있습니다.
<ng-include src="'views/header.html'"></ng-include>
언급URL : https://stackoverflow.com/questions/12521905/angularjs-ng-include-does-not-include-view-unless-passed-in-scope
'programing' 카테고리의 다른 글
| 정렬되지 않은 목록에 항목을 추가하는 방법정렬되지 않은 목록에 항목을 추가하는 방법jquery 사용 (0) | 2023.03.31 |
|---|---|
| python이 json 객체의 어레이에 추가됩니다. (0) | 2023.03.31 |
| 아티팩트 com.microsoft.sqlserver:sqljdbc4:jar:4.0 누락 (0) | 2023.03.31 |
| Go를 사용하여 JSON 응답을 제공하려면 어떻게 해야 합니까? (0) | 2023.03.31 |
| 여러 데이터 소스를 구성한 후 JPA 명명 전략을 설정할 수 없음 (Spring 1.4.1 / Hibernate 5.x) (0) | 2023.03.31 |