Angular -google-maps - "_contains is not a function" in chrome

I'm trying to use angular -google-maps, but it breaks in chrome with an error

TypeError: _.contains is not a function

My DOM element looks like

<div id="dashboard_map" class="tab-pane fade in active" ng-controller="mapsCtrl" ng-init="url = '/api/companies'; initialise();">
  <div class="panel panel-default"  ng-hide="!custom">
    <div class="panel-heading row">
      <div class="col-md-5">
        {!! Lang::get('google_maps.map1.title') !!}
      </div>
    <div class="col-md-2 col-md-offset-5">
      <i class="filter glyphicon glyphicon-filter pull-right" ng-click="custom=!custom"></i>
    </div>
  </div>
  <div class="panel-body">
    <div id="map_canvas">
        <ui-gmap-google-map center='map.center' zoom='map.zoom'>
        </ui-gmap-google-map>
    </div>
  </div>
</div>  

and I load gmap3, gmap3menu, lodash, angularjs, angular -resource, angular -simple-logger and finally angular-google maps in that order. My controller contains the following $ scope property

$scope.map = {center: {latitude: 40.1451, longitude: -99.6680 }, zoom: 4 };

A map is displayed, but I cannot get rid of this error.

Any ideas / tips are appreciated.

+4
source share
5 answers

angular -google- bower ( ) lodash 4. -, 3. * 4 "" "" "" "zipObject". , :

uiGmapGoogleMapApi.then(function(maps) {
      if( typeof _.contains === 'undefined' ) {
        _.contains = _.includes;
      }
      if( typeof _.object === 'undefined' ) {
        _.object = _.zipObject;
      }
      $scope.map = {..map stuff}
})

, , ,

+7

lodash ? contains includes 3.10.1, master. ( )

+4

angular -google-maps lodash 4 ( lodash _.contains _.includes [ 4]). lodash (, , lodash "bower install" ), angular -google- ( - https://github.com/angular-ui/angular-google-maps/issues/1682 )

+1

script index.html lodash lib

    <script>
    _.contains = _.includes;
   </script>
0

check this page: https://github.com/mgonto/restangular/issues/1298

_. contains an alias for _.includes..they deleted the alias .. ???

0
source

Source: https://habr.com/ru/post/1608440/


All Articles