저는 Angular-Formly를 사용하여 주소를 입력하고이 지역의지도를 반환하는 양식을 만듭니다.공식 맞춤형 템플릿을 사용하여 리플릿 맵을 초기화하는 방법은 무엇입니까?
<script type="text/ng-template" id="leaflet-map-template.html"> <div id="[options.key]"></div> </script>
과 함께 angular.module
에서 유형을 설정 다른 모듈 : 나는 다음과 같이 사용자 정의 템플릿을 생성하고있어
var app = angular.module('formlyExample', [
'ngAnimate',
'ngSanitize',
'ngTouch',
'formly',
'formlyBootstrap',
'ui.bootstrap'
], function config(formlyConfigProvider) {
// set custom template here
formlyConfigProvider.setType({
name: 'leaflet-map',
templateUrl: 'leaflet-map-template.html'
});
});
그러나 현장에서 나는를 초기화하는 방법을 모른다 전단지. 그것은 div
을 찾을 수 없기 때문에, Map container not found
:
vm.formFields = [
//other fields come here
//leaflet map template
{
key: 'mymap',
type: 'leaflet-map',
templateOptions: {
label: 'Leaflet Map'
},
controller: /* @ngInject */ function($scope) {
var initialCoordinates = [-23.0895164, -47.2187371];
// initialize map with initial coordinates
var map = L.map($scope.options.key, {
center: initialCoordinates,
zoom: 14,
zoomControl: false
});
}
}];
--EDIT-- 오류가 날 것입니다 제공 : 이것은 내 필드의 배열의 일부입니다.