I'm trying to build small application. It contains textarea and a button panel below wich is showing when I put first letter in this textarea. I had to use isButtonVisible() method. It works fine. The problem starts when i click on "send" a request with data from textarea to data.php script by method POST (it's point of my task. it have to be send() method). When request is done, script should show JavaScript alert() with "Data saved".
My angularjs script (ng-controller.js)
looks like:
angular.module("Textarea", []).controller("TextAreaCtrl", TextAreaCtrl);
function TextAreaCtrl($scope, $http)
{
'use strict';
$scope.success = false;
$scope.httpError = false;
this.isButtonVisible = function()
{
return $scope.text;
};
this.send = function ()
{
var data = $scope.text;
if(!data)
return false;
$http.post('data.php', data)
.success(function (data)
{
$scope.success = true;
})
.error(function (data)
{
$scope.httpError = true;
});
};
};