AJAX 发送方法和按钮可见性
AJAX send method and button visibility
因此,在输入第一个字符后显示的面板上有一个文本区域和发送按钮下方,isButtonVisible() 方法控制它。它通过 AJAX send() 方法将文本从 textarea 发送到 data.php,其中来自 textarea 的数据必须保存在 .txt 文档中。 .js 文件名为 ng-controllers.js 谁能帮我解决这个问题?我没有经验 angular.js
这是我的 HTML 文件的样子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl" ng-app="Textarea"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide{display:none !important;}ng\:form{display:block;}.ng-animate-block-transitions{transition:0s all!important;-webkit-transition:0s all!important;}.ng-hide-add-active,.ng-hide-remove{display:block!important;}</style>
<title>Angular - Textarea</title>
<link rel="stylesheet" type="text/css" href="./Angular - Textarea_files/style.css">
<script type="text/javascript" src="./Angular - Textarea_files/jquery.min.js"></script><style type="text/css"></style>
<script type="text/javascript" src="./Angular - Textarea_files/angular.min.js"></script>
<script type="text/javascript" src="./Angular - Textarea_files/ng-controllers.js"></script>
</head>
<body style="padding:0px; margin:0px;" onload="">
<div class="Cont" ng-controller="TextAreaCtrl as ctrl">
<div class="TextAreaCont">
<textarea ng-model="text" placeholder="Write something..." style="margin: 0px; height: 106px; width: 795px;"></textarea>
</div>
<div class="ButtonCont" ng-show="ctrl.isButtonVisible()">
<button ng-click="ctrl.send()">Send</button>
</div>
</div>
</body></html>
Ajax angualr 中的调用使用 $http
提供程序
full documentation here
这与您在 jquery 中 $.ajax 的做法非常接近,即
var httpPost = $http({
method: "post",
url: "example.com/posts",
data: {
// some data here
}
});
然后你将函数分配给 运行 就成功了
httpPost.success(
function( html ) {
// do something here
}
);
因此,在输入第一个字符后显示的面板上有一个文本区域和发送按钮下方,isButtonVisible() 方法控制它。它通过 AJAX send() 方法将文本从 textarea 发送到 data.php,其中来自 textarea 的数据必须保存在 .txt 文档中。 .js 文件名为 ng-controllers.js 谁能帮我解决这个问题?我没有经验 angular.js
这是我的 HTML 文件的样子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl" ng-app="Textarea"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide{display:none !important;}ng\:form{display:block;}.ng-animate-block-transitions{transition:0s all!important;-webkit-transition:0s all!important;}.ng-hide-add-active,.ng-hide-remove{display:block!important;}</style>
<title>Angular - Textarea</title>
<link rel="stylesheet" type="text/css" href="./Angular - Textarea_files/style.css">
<script type="text/javascript" src="./Angular - Textarea_files/jquery.min.js"></script><style type="text/css"></style>
<script type="text/javascript" src="./Angular - Textarea_files/angular.min.js"></script>
<script type="text/javascript" src="./Angular - Textarea_files/ng-controllers.js"></script>
</head>
<body style="padding:0px; margin:0px;" onload="">
<div class="Cont" ng-controller="TextAreaCtrl as ctrl">
<div class="TextAreaCont">
<textarea ng-model="text" placeholder="Write something..." style="margin: 0px; height: 106px; width: 795px;"></textarea>
</div>
<div class="ButtonCont" ng-show="ctrl.isButtonVisible()">
<button ng-click="ctrl.send()">Send</button>
</div>
</div>
</body></html>
Ajax angualr 中的调用使用 $http
提供程序
full documentation here
这与您在 jquery 中 $.ajax 的做法非常接近,即
var httpPost = $http({
method: "post",
url: "example.com/posts",
data: {
// some data here
}
});
然后你将函数分配给 运行 就成功了
httpPost.success(
function( html ) {
// do something here
}
);