※Onsen UI V2.8.3 + Angular JS V1.6.6
[onsenui]・[js]フォルダにそれぞれ必要ファイルを配置すること。
事前にLINE・Twitterのアプリをインストールすること。
otak-lab
otak-lab
I am developing an app.
※2018/01/10 コード訂正済み。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> <script src="js/angular.min.js"></script> <script src="components/loader.js"></script> <script src="onsenui/js/onsenui.min.js"></script> <script src="onsenui/js/angular-onsenui.min.js"></script> <link rel="stylesheet" href="components/loader.css"> <link rel="stylesheet" href="onsenui/css/onsenui.min.css"> <link rel="stylesheet" href="onsenui/css/onsen-css-components.min.css"> <link rel="stylesheet" href="css/style.css"> <script> var app = angular.module("myApp", ["onsen"]); app.controller("indexController", function ($scope) { $scope.hashtag = "テスト"; $scope.message = "よろしくお願いします。"; ons.ready(function () { }); // LINEに送信 $scope.sendLine = function () { var url = "http://line.me/R/msg/text/"; var data = url + encodeURIComponent($scope.message + " #" + $scope.hashtag); window.open(data, "_system"); }; // Twitterに送信 $scope.sendTwitter = function () { var url = "https://twitter.com/intent/tweet?"; var data = url + "text=" + encodeURIComponent($scope.message) + "&hashtags=" + encodeURIComponent($scope.hashtag); window.open(data, "_system"); }; }); </script> </head> <body> <ons-page ng-controller="indexController"> <ons-toolbar> <div class="center">テスト</div> </ons-toolbar> <ons-list> <ons-list-item> <ons-button modifier="large" ng-click="sendLine()">LINE</ons-button> </ons-list-item> <ons-list-item> <ons-button modifier="large" ng-click="sendTwitter()">Twitter</ons-button> </ons-list-item> </ons-list> </ons-page> </body> </html> |