【发布时间】:2018-09-20 12:41:33
【问题描述】:
如何将数据从 angularjs 控制器发送到 Android Studio 中的 MainActivity。
这是 MainActivity:
package at.restaurantKellner;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
这是我的 Angular controller.js:
'use strict';
window.App.Module = angular.module('AppModule.tisch-details', ['ngRoute']);
window.App.Ctrls.controller('tisch-detailsCtrl', ['$scope', '$http', '$location', '$timeout', '$route', '$rootScope', 'ngDialog', 'czs', '$sce', '$q', 'user', function ($scope, $http, $location, $timeout, $route, $rootScope, ngDialog, czs, $sce, $q, user) {
//I want to send this information to MainActivity
$scope.dataForMainActivity = "Data to send";
}]);
有人可以给我写一个示例代码吗?我将不胜感激
【问题讨论】: