Comments (1)
首先我解释下这个问题可能发生的情况:
1、第一种情况,与demo.html中文件结构相同的时候,如果你使用$scope.myMap是null的情况,是由于地图未初始化完成,因为controller是会先一步初始化完成,所以安全的做法是在onMapLoaded方法被调用之后,再使用$scope.myMap对象
2、当你的界面结构比较复杂的时候,而此时你是通过data-ng-include进来的界面的情况下,你的地图引用可能是被绑定到了上一层Controller的$scope对象下
声明一下,这个并不需要你的$scope去声明myMap,指令会自动帮你创建这个属性,具体操作请看src/angularjs-baidu-maps.js文件中第55行里面是通过model.assign(scope, map);将当前的地图引用设置给$scope
具体$parse的用法,请参考 https://docs.angularjs.org/api/ng/service/$parse
具体src中第55行功能,请参考文档$parse内容中右下角最后一行对assign 的解释
from angular-baidu-maps.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-baidu-maps.