본인은 app-header
에 대한 조회가 가능하며 본문 내용 ng-view
에 대한 조회가 있습니다. 기본적으로 프로필 본문에 ng-model 입력이 있으며로드 될 때 헤더의 어떤 것에 바인딩하려고합니다. NG-모델과 바인딩이 같은 뷰에있는 경우다른보기에서 ng-model/bind를 사용하는 방법은 무엇입니까?
나는 아무 문제가 없지만, 범위를 가로 질러 이동하는 바인딩을 얻을하는 방법을 잘 :
<!-- Main Nav -->
<app-header></app-header>
<div class="content_container">
<!-- angular templating content will be injected here -->
<div ng-view></div>
</div>
입력 프로파일 구성 요소에서
<input ng-model="profile_name" type="text" id="profile_first_name" name="profile_first_name"/>
헤더
<div class="user_badge">{{profile_name}}</div>
헤더 지침
// Directive for Header
app.directive('appHeader', function() {
// Type of Directive, E for element, A for Attribute
// url of a template
return {
restrict: 'E',
templateUrl: 'shared/navigation/header.html'
};
});
ProfileController
// Controller for Profile
app.controller('ProfileController', function() {
});
// Controller for Complete Registration
app.controller('CompleteRegistrationController', function() {
});
// configure our routes
app.config(['$routeProvider', function($routeProvider) {
$routeProvider
// route : Edit Profile
.when('/profile', {
title : 'Edit Profile',
templateUrl : 'components/profile/edit-profile.html',
controller : 'ProfileController'
});
}]);
당신이 어디에 연결하려고하는 것을 이해할 수 없었다? – Linial
나는 그 제목 아래의 편집 프로필 부분에 프로필 이름을 입력하는 동안 제목의 프로필 이름 만 업데이트하려고한다고 생각합니다. 나는 공장과 같은 것을 해결할 것이라고 생각한다. 사용자 저장소에 액세스해야 할 때마다 주입 할 수 있으며 쉽게 테스트 할 수 있습니다. 그게 옵션일까요? – timtos
그래, 좋을거야, 아직 공장을 사용하지 않았어 ... –