2016-04-10 3 views
0

私はhtml/css/jsのWebサイトとangularJS(ionic framework)のモバイルアプリケーションを開発しています。私のウェブサイトでは、私はGoogleの地理位置とフルカレンダー(http://fullcalendar.io/)を実装しています。私はangularJSで使用するために使用可能なディレクティブがあることを知っているが、私は急いでいるので、私は私の通常のhtml/css/jsのWebサイトから私のfullcalendarとgeolocation Javascriptをコピーして私のangularJSアプリのテンプレート。どんな提案も高く評価されます。通常のjavascriptとcssの機能を私のウェブサイトからanglejsアプリに組み込むことは可能ですか?

EDIT:

ここでは、私はジオロケーション更新のために使用していたコードの例です。

<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

これを使用してコントローラを実行することができ

例に、そのコントローラを発射あなたはそのrouteまたは任意のイベントで実行する予定javascriptのいずれかを実行します。この方法質問は、ちょうど明確な答えを提供するにはあまりにも広すぎます。 fullcalendarのようなJQueryプラグインは、角度と共存することは間違いありませんが、タイミングの問題がある可能性があります。コードで現在の使用シナリオの例がなくても影響を受けるかどうかは分かりません。 – Claies

+0

@Claies編集に自分のコードの例が含まれています。私のfullcalendarコードを見たい場合は、ここでもそれを少しでも長く投稿できます。 –

+0

間違いなく可能です。しかし、それは悪い習慣です。なぜなら、角度をつけて何をしなければならないかは、適切な方法で行われるべきだからです。スタンドアロンコードではありません。 – AceLearn

答えて

1

それは間違いなく可能ですが、あなたはちょうどあなたが通常の角度のコントローラにあなたのbodyheadタグ内のどこにでも置くすべてのコードを配置する必要があります。 あなたのコントローラは、あなたが

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

は、その後、あなたが通常の角度ディレクティブ

+0

Arge、ウェブページでテンプレートの

関連する問題