私はAngular-Formlyを使ってアドレスを入力し、このローカルからマップを返すフォームを作成しています。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-- エラーそれは私が与える:これは私のフィールドアレイの一部です。