$scope
에는 국가 목록에서 선택시 iso 코드를 표시해야합니다.
그래서 국가 목록은 $에 http 전화 공장을 인출되고 있으며 지금까지 그래서 여기에 좋은 사용자가 국가를 위해 입력 한 곳
///////// get countries ////////////////
tableFactory.getCountries().then(function(data){
$scope.presentCountries = data;
});
presentCountries
이 typeahead
로 전송됩니다, 범위로 채 웁니다 과 같이, 선택 :이 선택 일단
<div class="countrySearchField">
<div class="row">
<h3 class="searchTitle">Pick a country</h3>
</div>
<input type="text" class="form-control search-input" ng-model="countryPicked" uib-typeahead="presentCountry.name for presentCountry in presentCountries | filter:{name: $viewValue}:startsWith" typeahead-min-length="1" typeahead-on-select="onSelectCountry($item, $model, $label)" typeahead-editable="false"/>
</div>
, 그것은 범위 기능 onSelectCountry
를 호출합니다.
$scope.onSelectCountry = function($item, $model, $label){
$scope.brandCountryCode = $item.iso_code_2;
// $scope.brandCountryCode = $item;
console.log($scope.brandCountryCode);
}
내가 아닌 모달 뷰 (오버레이보기)에서, CONSOLE.LOG에서 콘솔, 데이터, $scope.brandCountryCode
을 볼 수 있습니다.
<div class="row subtitleModalRow">
<h5 class="unlock-description">Please check the following parameters before merging</h5>
<!-- <p class="unlock-description" ng-bind-html="overlayMessage"></p> -->
<ul>
<li>Brand Country: {{brandCountryCode}}</li>
</ul>
</div>
왜 표시되지 않는지 이해할 수 없지만 console.log 출력을 볼 수 있습니다. 나는 scope가 함수 아래에 있기 때문에 의심 스럽지만, $scope
에 값을 설정하면, 내가 틀렸다면 어디서나 사용할 수 있어야한다고 생각합니다.
또한 오버레이보기는 선행 텍스트 HTML과 별도의 HTML 파일 일 수 있습니다. 그러나이 오버레이 뷰는 컨트롤러가 tablePageCtrl
입니다. 컨트롤러는 두 html 파일에 모두 존재해야합니다.
this.openModal = function(type) {
this.type = type;
if(type == 'mergeRequest'){
var templateUrl = 'app/views/dataMerge/overlayMsg.html';
var backdropClass = 'auth-backdrop';
var controller = 'tablePageCtrl';
}
this.modalInstance = $uibModal.open({
animation: true,
templateUrl: templateUrl,
controller: controller,
windowTopClass: 'auth-template',
backdrop: 'static',
backdropClass: backdropClass,
});
};
나는 컨트롤러의
$scope.test = 'test'
라는 함수 외부 테스트를했고, 나는 오버레이 뷰의 값을 참조하십시오. 나는 함수 아래에있는이 범위로 실행되는
onSelect
함수를 기반으로하는 다른 범위가 있습니다.
초기화 도구 $scope.brandCountryCode = ''
을 추가했지만 아무것도하지 않았습니다. 내가 이걸 풀 수 있다면, 다른 것들은 괜찮을거야.
여기에 무슨 일이 일어나는지 확실하지 않은 사람이 누구나 제안을합니다. 앵귤러를 아직 처음 접했고 도움을 받으실 수 있습니다. 감사!
편집
오버레이 모달을위한 풀 서비스 코드 :
(function() {
'use strict';
angular
.module('com.xad.se-tools')
.service('tableModalService', function($scope, $uibModal){
this.modalInstance = null;
this.type = null;
this.openModal = function(type) {
this.type = type;
if(type == 'mergeRequest'){
var templateUrl = 'app/views/dataMerge/overlayMsg.html';
var backdropClass = 'auth-backdrop';
var controller = 'tablePageCtrl';
}
this.modalInstance = $uibModal.open({
animation: true,
templateUrl: templateUrl,
// controller: 'AuthCtrl',
controller: controller,
windowTopClass: 'auth-template',
backdrop: 'static',
backdropClass: backdropClass,
scope: $scope
});
};
this.closeModal = function() {
this.modalInstance.dismiss('cancel');
}
});
})();
당신은 아마도 [JavaScript Prototype Inheritance] (http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs)의 희생자 일 수 있습니다. 근본적으로 모달은 상위 페이지와 다른 범위를 가지며 페이지의 값은 숨겨집니다. @Bartekfyzowicz가 제공 한 답을 사용할 수도 있고 (동일한 범위를 사용하도록 모달을 적용하십시오), 각도의 ** 황금률 **을 따르십시오 : ** "각도 바인딩에서 항상 점 사용"**. – Claies