ng-click不在控制器中声明的离子框架中工作

时间:2016-07-27 06:21:05

标签: javascript angularjs cordova ionic-framework

点击infowindow点击我要导航到其他页面..

.controller('MapCtrl', function ($scope, $state, $cordovaGeolocation, $compile) {
var myLatlng = new google.maps.LatLng(21.117181, 79.070339);

var mapOptions = {
    center: myLatlng,
    zoom: 11,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
    mapOptions);
var contentString = "<button ng-click='gotoBooking()'>Book</button>";
var compiled = $compile(contentString)($scope);

var infowindow = new google.maps.InfoWindow({
    content: compiled[0]
});

var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
});

marker.addListener('click', function () {
    infowindow.close();
    infowindow.open(map, marker);
});

var myLatlng2 = new google.maps.LatLng(21.16581, 79.070339);

var marker2 = new google.maps.Marker({
    position: myLatlng2,
    map: map,
});

marker2.addListener('click', function () {
    infowindow.close();
    infowindow.open(map, marker2);
});

$scope.map = map;
$scope.gotoBooking = function () {

    $state.go('app.makeBooking');
};

});

0 个答案:

没有答案