android input/output 流在 typescript/javascript 中的等效项
What is equivalent of android input/output stream in typescript/javascript
实际上我需要将数据从 Angular
发送到 android 设备。要求是通过 android input/output stream
方法将数据发送到正在接受的 android 设备。
如果您不明白我在说什么,请帮助我并纠正我。如何将数据从 angular 发送到 android 设备,知道其 ip
和 port
.
更新
我已经更新了我的标题,希望现在清楚了
在浏览器中没有 stdin
,也称为控制台。输入很可能来自用户在页面上以输入字段的形式输入。
很可能您的结构设置如下:
Angular (browser) > API (server) > GCM (push) > Android Device
这是一个示例,说明如何从用户那里获取输入并将其发送到后端 api,GCM 部分很可能已经为您的团队项目配置好了。
const theForm = document.forms.theForm;
theForm.addEventListener('submit', (event) => {
event.preventDefault();
const data = new FormData(theForm);
data.append('movies', ["I Love You Man", "Role Models"]);
fetch(
'https://reqres.in/api/users',
{
method: 'POST',
body: JSON.stringify(data),
})
.then(resp => resp.json())
.then(data => console.log(data));
});
<form name="theForm">
<input type="text" name="name" placeholder="name" />
<button type="submit">Submit</button>
</form>
实际上我需要将数据从 Angular
发送到 android 设备。要求是通过 android input/output stream
方法将数据发送到正在接受的 android 设备。
如果您不明白我在说什么,请帮助我并纠正我。如何将数据从 angular 发送到 android 设备,知道其 ip
和 port
.
更新
我已经更新了我的标题,希望现在清楚了
在浏览器中没有 stdin
,也称为控制台。输入很可能来自用户在页面上以输入字段的形式输入。
很可能您的结构设置如下:
Angular (browser) > API (server) > GCM (push) > Android Device
这是一个示例,说明如何从用户那里获取输入并将其发送到后端 api,GCM 部分很可能已经为您的团队项目配置好了。
const theForm = document.forms.theForm;
theForm.addEventListener('submit', (event) => {
event.preventDefault();
const data = new FormData(theForm);
data.append('movies', ["I Love You Man", "Role Models"]);
fetch(
'https://reqres.in/api/users',
{
method: 'POST',
body: JSON.stringify(data),
})
.then(resp => resp.json())
.then(data => console.log(data));
});
<form name="theForm">
<input type="text" name="name" placeholder="name" />
<button type="submit">Submit</button>
</form>