Sie sind auf Seite 1von 8

bootstrap icons

http://getbootstrap.com/components/

--------------------------------------------------------------------------

AngularJS is constantly updating the state of both the form and the input fields.

Input fields have the following states:

$untouched - The field has not been touched yet


$touched - The field has been touched
$pristine - The field has not been modified yet
$dirty - The field has been modified
$invalid - The field content is not valid
$valid - The field content is valid

They are all properties of the input field, and are either true or false.

Forms have the following states:

$pristine - No fields have been modified yet


$dirty - One or more have been modified
$invalid - The form content is not valid
$valid - The form content is valid
$submitted - The form is submitted

They are all properties of the form, and are either true or false.

<form ng-app="myApp" ng-controller="validateCtrl"


name="myForm" novalidate>

<p>Username:<br>
<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">Username is required.</span>
</span>
</p>

<p>Email:<br>
<input type="email" name="email" ng-model="email" required>
<span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
<span ng-show="myForm.email.$error.required">Email is required.</span>
<span ng-show="myForm.email.$error.email">Invalid email address.</span>
</span>
</p>

<p>
<input type="submit"
ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
myForm.email.$dirty && myForm.email.$invalid">
</p>

</form>

<script>
var app = angular.module('myApp', []);
app.controller('validateCtrl', function($scope) {
$scope.user = 'John Doe';
$scope.email = 'john.doe@gmail.com';
});
</script>

------------------------------------------------
<input type="number"
ng-model="string"
[name="string"]
[min="string"]
[max="string"]
[ng-min="string"]
[ng-max="string"]
[step="string"]
[ng-step="string"]
[required="string"]
[ng-required="string"]
[ng-minlength="number"]
[ng-maxlength="number"]
[pattern="string"]
[ng-pattern="string"]
[ng-change="string"]>

--------------------------------------------------
deleteUser = $window.confirm('Are you sure you want to delete the record?');
if(deleteUser){

$http.post("http://localhost:8080/mssqlwater/includes/api/connection_delete.php",
{id: id})
.then(function(){
$scope.message = "Successfully Deleted";
$scope.messageStatus = "alert alert-danger";
$scope.msgBox = true;
$timeout(function(){
$scope.msgBox = false;
}, 1000);
$scope.selectData();
});

-----------------------------------------------------------------------------------
----------
var app = angular.module("mySettings", ['ngRoute']);

app.config(function($routeProvider) {
$routeProvider.
when("/cubic", {
templateUrl: "pages/cubic.htm",
controller: "myCubicSettingsController"
}).
when("/typecon", {
templateUrl: "pages/typecon.htm",
controller: "myConnectionSettingsController"
}).
when("/download", {
templateUrl: "pages/download.htm",
controller: "myDownloadSettingsController"
}).
when("/upload", {
templateUrl: "pages/upload.htm",
controller: "myUploadSettingsController"
});

console.log('here');
});

app.controller("myConnectionSettingsController", function($scope, $http,


$timeout, $window){
var tmpid=0;
var tmpobj=null;

$http.get('http://localhost:8080/mssqlwater/includes/api/connection_list_row.php').
then(function(response){
$scope.connections = response.data;
});

//selectData();

$scope.insertData = function(){
ans = $window.confirm('Are you sure you want to add this
record?');

if (ans){

$http.post("http://localhost:8080/mssqlwater/includes/api/connection_add.php",
{type: $scope.type, minrate: $scope.minrate, mincubic: $scope.mincubic, percubic:
$scope.percubic, tax: $scope.tax, status: $scope.status})
.then(function(){
$scope.message = "Successfully Submited!";
$scope.msgBox = true;
$scope.type = "";
$scope.minrate = "";
$scope.mincubic = "";
$scope.percubic = "";
$scope.tax = "0.0";
$scope.status = "Active";
$timeout(function(){
$scope.msgBox = false;
}, 1000);
$scope.selectData();
});
}
}

$scope.selectData = function(){

$http.get('http://localhost:8080/mssqlwater/includes/api/connection_list_row.php').
then(function(response){
$scope.connections = response.data;
});
//alert('hello');
}
$scope.btnInsert = true;

$scope.updateData = function(mem_id){
$scope.btnUpdate = false;
$scope.btnInsert = true;

$http.post("http://localhost:8080/mssqlwater/includes/api/connection_edit.php",
{id: $scope.id, type: $scope.type, minrate: $scope.minrate, mincubic:
$scope.mincubic, percubic: $scope.percubic, tax: $scope.tax, status:
$scope.status})
.then(function(response){
$scope.type = "";
$scope.minrate = "";
$scope.mincubic = "";
$scope.percubic = "";
$scope.tax = "0.0";
$scope.status = "Active";
$scope.id = "";
$scope.message = "Successfully Updated";
$scope.messageStatus = "alert alert-success";
$scope.msgBox = true;
$timeout(function(){
$scope.msgBox = false;
}, 1000);
$scope.selectData();
});
}

$scope.updateBtn = function(objcon){
$scope.btnInsert = false;
$scope.btnUpdate = true;

$scope.id = objcon.id;
$scope.type = objcon.type;
$scope.minrate = parseInt(objcon.minrate);
$scope.mincubic = parseInt(objcon.mincubic);
$scope.percubic = parseInt(objcon.percubic);
$scope.tax = parseInt(objcon.tax);
$scope.status = objcon.status;

$scope.deleteData = function(id){
deleteUser = $window.confirm('Are you sure you want to delete the
record?');
if(deleteUser){

$http.post("http://localhost:8080/mssqlwater/includes/api/connection_delete.php",
{id: id})
.then(function(){
$scope.message = "Successfully Deleted";
$scope.messageStatus = "alert alert-danger";
$scope.msgBox = true;
$timeout(function(){
$scope.msgBox = false;
}, 1000);
$scope.selectData();
});

}
}

});

app.controller("myDownloadConnSettingsController", function($scope, $http){

});

-------------------------------------------------------------------------

$scope.basket = [];
$scope.basket = [
{'id': '1','name': 'T-Shirt', 'quantity': 2, 'cost': 1.10,
'subtotal': 2.20},
{'id': '2','name': 'Jeans', 'quantity': 2, 'cost': 1.99,
'subtotal': 2.20},
{'id': '3','name': 'Jacket', 'quantity': 1, 'cost': 3.22,
'subtotal': 3.22}
];

angular.forEach($scope.basket, function(item) {
$scope.addItem(item);
});

// Add item to basket


$scope.addItem = function(data)
{
$scope.basket.push({
'id': data.id,
'product': data.name,
'cost': data.cost,
'quantity': data.quantity,
'subtotal': data.subtotal
});
}

// Drop an item from the basket


$scope.dropItem = function(index)
{
$scope.basket.splice(index, 1);
}

// Get the running total of the basket


$scope.getOrderTotal = function(){
var total = 0;
angular.forEach($scope.basket, function(item) {
total = parseInt(total) + parseFloat(item.subtotal, 2);
});
return total;
}

-------------------------------------------------------

`id`, `consumerid`, `invoiceno`, `amountpayed`, `change`,


`dateofpayment`, `remarks`, `lastedit`, `lasteditby`, `datedeleted`, `deletedby`
----------------------------------------------------------------

<input type="number" ng-change="recompute()" ng-model = "quantity"


id="quantity" class="form-control" required>

$scope.recompute = function ($event) {


$scope.subtotal = parseFloat($scope.quantity) *
parseFloat($scope.itemselected.price);
};

--------------------------------------------------------
search in json

$scope.findSetting = function(_id){
var found = $scope.settings.filter(function(setting){ return
setting.id === _id });
return JSON.stringify(found);
};

-------------------------------------------------------
$today = date('Y-m-d');
$stop_date = new DateTime($today);
$stop_date->modify('+1 day');

echo $today . ' - ' . $stop_date->format('Y-m-d');

------------------------------------------------------------------

$scope.currentbalance = parseFloat(minrate) + parseFloat($scope.prevbalance);

---------------------------------------------------------------
//create billing record
$billing = new Billing();
$billing->consumerid = $data->id;
$billing->date = date("Y-m-d");
$billing->qtydelivered = 0;
$billing->amount = $data->total;
$billing->discount = 0.0;
$billing->total = $billing->amount - $billing->discount;
$billing->status = "pending";
$billing->processedby = "";
$billing->type = "new";
$billing->remarks = "";
$billing->readingno = $readingid;
$insertid = $billing->create();

//dump to billing items table


foreach($items as $item){
$billingitem = new BillingItem();
$billingitem->billingid = $insertid ;
$billingitem->itemid = $item->id;
$billingitem->quantity = $item->quantity;
$billingitem->price = $item->cost;
$billingitem->amount = $item->subtotal;
$billingitem->remarks = "pending";
$billingitem->datetime = date("Y-m-d h:i:sa");

$billingitem->create();
}

---------------------------------------------------------------

http://angular-ui.github.io/bootstrap/versioned-docs/0.12.0/

--------------------------------------------------------

Get the length of json abject

function length(obj) {
return Object.keys(obj).length;
}

Now you can call this function like this

length (data); // returns 1


length (data.name_data) // returns 4

v7fz76
------------------------------------------------------------------
angular for Each
var values = [{ "Name" : "Thomas", "Password" : "thomasTheKing" },
{ "Name" : "Linda", "Password" : "lindatheQueen" }];
angular.forEach(values, function(value, key){
console.log(key + ': ' + value);
});
// it will log two iteration like this
// 0: [object Object]
// 1: [object Object]

-----------------------------------------------------------------------------
--

angular NgTables
http://techqa.info/programming/tag/ngtable?after=41678086

-----------------------------------------------------------------------------
--
Date input in angular
<label class="col-sm-2 control-label" for="textinput">Bill To</label>
<div class="col-sm-4">
<input type="Date" class="form-control" ng-model="billto.value"
required/>
</div>

--------------------------------------------------------------------
Format date yyyy-mm-dd

var from = $filter('date')($scope.datefrom.value,'yyyy-MM-dd');


var to = $filter('date')($scope.dateto.value,'yyyy-MM-dd');

-----------------------------------------------------------------------
Secco Inventory
SELECT itemid, sum(qty) as credit, sum(dqty) as debit, (sum(qty) - sum(dqty))
as volume FROM `inventory` group by userid, itemid

1) PO from customer
- warehouseid = destination to customer
- centerid = source

Das könnte Ihnen auch gefallen