![](/img/trans.png)
[英]Can I include this JavaScript/NodeJS/express app in my website?
[英]Is it possible to include normal javascript and css functions from my website into my angularjs app?
我正在用html / css / js开发一个网站,并在angularJS(离子框架)中开发它的移动应用程序。 在我的网站中,我已经实现了google geolocation和完整日历( http://fullcalendar.io/ )。 我知道要在angularJS中使用,但有一些可用的指令,但是由于我很着急,所以我需要知道是否有可能从普通的html / css / js网站复制全日历和地理位置Javascript并将其粘贴到我的angularJS应用模板。 任何建议将不胜感激。
编辑:
这是我用于地理位置更新的代码示例。
<script>
if ("geolocation" in navigator)
{
request_location();
}
// Requesting location from user
function request_location()
{
// Will repeat the process in two minutes
setTimeout(request_location, 1000*60*2);
// Get location info from browser and pass it to updating function
navigator.geolocation.getCurrentPosition(update_location);
}
// Sending location to server via POST request
function update_location(position)
{
// For simplicity of example we'll
// send POST AJAX request with jQuery
$.post( "functions.php?action=update_geolocation", { latitude: position.coords.latitude, longitude: position.coords.longitude });
//$.post("functions.php?action=update_geolocation&latitude="+ position.coords.latitude + '&longitude=' + position.coords.longitude,
/* {
latitude : position.coords.latitude,
longtitude : position.coords.longitude
},*/
// function(){
// // Position sent, may update the map
// });
}
</script>
绝对有可能,您只需要将通常会放在body
或head
标签中任何地方的所有代码放入角度控制器即可。 这样,您的控制器将执行您打算在该route
上执行的任何JavaScript或触发该控制器的任何事件
例
myApp.controller('exampleController', ['$scope', function($scope) {
if ("geolocation" in navigator) {
request_location();
}
// Requesting location from user
function request_location() {
// Will repeat the process in two minutes
setTimeout(request_location, 1000 * 60 * 2);
// Get location info from browser and pass it to updating function
navigator.geolocation.getCurrentPosition(update_location);
}
// Sending location to server via POST request
function update_location(position) {
// For simplicity of example we'll
// send POST AJAX request with jQuery
$.post("functions.php?action=update_geolocation", {
latitude: position.coords.latitude,
longitude: position.coords.longitude
});
//$.post("functions.php?action=update_geolocation&latitude="+ position.coords.latitude + '&longitude=' + position.coords.longitude,
/* {
latitude : position.coords.latitude,
longtitude : position.coords.longitude
},*/
// function(){
// // Position sent, may update the map
// });
}
}]);
然后,您可以使用常规角度指令执行控制器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.