我正在尝试将这个:https://github.com/kuhnza/angular-google-places-autocomplete 模块添加到我的意思应用程序中。我使用 bower 进行安装,其中包括以下示例。
<!DOCTYPE html>
<html ng-app="example">
<head lang="en">
<!-- Required dependencies -->
<script src="https://maps.googleapis.com/maps/api/js?&libraries=places"></script>
<script src="/lib/angular/angular.js"></script>
<!-- Google Places Autocomplete directive -->
<script src="/lib/angular-google-places-autocomplete/src/autocomplete.js"></script>
<script>
angular.module('example', ['google.places'])
// Setup a basic controller with a scope variable 'place'
.controller('MainCtrl', function ($scope) {
$scope.place = null;
});
</script>
</head>
<body ng-controller="MainCtrl">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Basic Usage</h1>
<form class="form">
<input class="form-control" g-places-autocomplete ng-model="place"/>
</form>
<h5>Result:</h5>
<pre>{{place | json}}</pre>
</div>
</div>
</div>
</body>
</html>
当我在本地主机上运行我的应用程序并键入与示例位置相对应的 url 时,一切正常。但是,如果我将此代码复制并粘贴到视图中.html并点击指向此文件的链接,则该代码不起作用。现在,如果我在config.js中将"google.places"添加到var applicationModuleVendorDependencies
数组中,则会出现以下错误。
Uncaught Error: [$injector:modulerr] Failed to instantiate module borowr due to:
Error: [$injector:modulerr] Failed to instantiate module google.places due to:
Error: [$injector:nomod] Module 'google.places' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
将第三方模块添加到平均应用程序的正确方法是什么?
看起来您走在正确的轨道上,您是否将该视图的依赖项注入到控制器中?
在向我的平均应用程序添加第 3 方模块时,我遇到了同样的问题。 检查此链接: https://stackoverflow.com/a/36032008/6044269
这就是将ngDialog添加到我的意思应用程序的方式,除了CSS文件之外,对您来说应该是相同的。
据我所知,这是我设法添加 3rd 方模块的唯一方法。