谷歌地图是以javascript方式集成的,我想在infowindow中调用angular2函数,如下面的代码.看看infoContent按钮.
for (i = 0; i < locations.length; i++) {
let locLatLng = new google.maps.LatLng(locations[i].latitude, locations[i].longitude);
let infoContent = '<button (click)="myFunction(' + locations[i].id + ')">Details ...</button>';
marker = new google.maps.Marker({
position: locLatLng,
map: this.map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(infoContent);
infowindow.open(this.map, marker);
};
})(marker, i));
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,角点击事件(click)="myFunction()"无法做到.必须有另一种方式.如果有人能指出我正确的方向,我会很高兴.提前致谢.
我想在Ionic 2项目中使用Angular 2的国际化(i18n).不幸的是,我无法使用ng-xi18n工具尝试以下命令创建翻译源文件:
./node_modules/.bin/ng-xi18n
Run Code Online (Sandbox Code Playgroud)
出现以下TypeError:
TypeError: Cannot read property 'create' of undefined
at Function.Extractor.create (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extractor.js:69:45)
at extract (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extract_i18n.js:7:34)
at Object.main (/Users/user/Development/app/node_modules/@angular/tsc-wrapped/src/main.js:47:16)
at Object.<anonymous> (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extract_i18n.js:14:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
Extraction failed
Run Code Online (Sandbox Code Playgroud)
我尝试升级我的软件包但没有成功.这里是我在文件中的依赖项package.json
"dependencies": {
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/compiler-cli": "^2.4.0",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/platform-server": "^2.4.0",
"es6-shim": "0.35.1",
"ionic-angular": "2.0.0-beta.11",
"ionic-native": "1.3.10",
"ionicons": "3.0.0",
"reflect-metadata": "0.1.8", …Run Code Online (Sandbox Code Playgroud)