2016-04-10 40 views
0

html/css/js ve mobil uygulamasında angularJS (iyonik çerçeve) içinde bir web sitesi geliştiriyorum. Web sitemde google geolocation ve tam takvim (http://fullcalendar.io/) uyguladım. Ben angularJS, kullanım için direktifler mevcut olduğunu biliyorum, ama acelem var beri, bu benim normal html/css/js web sayfamdan fullcalendar ve geolocation Javascript üzerinden kopyalamak mümkün ve bunu benim yapıştırmak gerekir angularJS uygulaması şablonu. Herhangi bir öneri son derece takdir edilecektir.Web sitemden normal javascript ve css işlevlerini angularjs uygulamasına eklemek mümkün mü?

DÜZENLEME: İşte

Ben coğrafi konum güncelleme için kullanıyorum kod örneğidir.

<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> 
+1

Bu kullanarak kontrolörü yürütebileceği

Örneğin o denetleyici ateş Bunu route ya da her türlü olaya yürütmek niyetinde JavaScript herhangi çalıştırır Bu şekilde Soru sadece kesin bir cevap vermek için biraz fazla geniş. Tamcalendar gibi JQuery eklentilerinin açısal ile birlikte var olması kesinlikle mümkündür, ancak zamanlama sorunları olabilir ve bunlar eğer geçerli kullanım senaryonuzun bir örneği olmadan sizi etkileyeceklerse kesin olarak bilinemeyecektir. – Claies

+0

@Claies Düzenlememde kodumun bir örneğini ekledim, Eğer fullcalendar koduma bir göz atmak istersen, bunu da gönderebilirim, biraz uzun olsa da –

+0

Kesinlikle mümkün. Ama bu kötü bir uygulama. Çünkü ne yapmanız gerekiyorsa açısal olarak doğru bir şekilde yapılmalıdır. Bağımsız bir kod olarak değil. – AceLearn

cevap

1

Kesinlikle mümkündür, sadece normalde açısal denetleyicileri içine body veya head etiketleri yerde koyardı tüm kodu koymak gerekir. Denetleyiciniz Eğer

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 
    // }); 
    } 
}]); 

Sonra normal açısal direktifleri

+0

Arge, Web sayfasında yaptığım gibi şablona neden sadece