Wednesday, August 6, 2014

Basic Html page with Angular js in 2mins

We only need one html file for this. We can also use three files for this purpose.

1. Angular.js file – this is the main javascript file we need to make page support for Angular js. We can include it in our folder or we can directly take it from CDN.

2. Basic Html file – this file should contain ng-app in any HTML tag. ng-controller,ng-repeat and {{variable}} are code syntaxes.

3. CardController.js file -  this file contains controller class and with $scope variable it defines its parameters.

<html ng-app xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<!--<script src="scripts/angular.min.js"></script>-->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
<script language="javascript">
//we can also use CardController.js for this
var CardController = function ($scope) {
$scope.cards
= [{ Id: 1 }, { Id: 4 }];
};
</script>
</head>
<body ng-controller="CardController">
<div ng-repeat="card in cards" class="CardItem">
Id: {{card.Id}}
</div>
</body>
</html>

Output will be
Id: 1
Id: 4


Hope you wanted to learn more simple beginners lessons on AngularJS covering most parts with examples. W3Cschools.com - http://www.w3schools.com/angular/default.asp

Tuesday, August 5, 2014

Remove Carriage Return, Line Feed, Tab in TSQL

Following code shows way to remove all spaces from selected column values. We generally use RTRIM and LTRIM build in string functions but sometimes it doesn’t remove some spaces due to string contains carriage return life feed and tab like control characters. We can’t see these characters with grid result view but we can see in text result view in MSS Management Studio.

REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(ColumnName)), CHAR(10), ''),CHAR(13), ''),CHAR(9), '')
CHAR(9) - 'Tab'
CHAR(10) - 'Line Feed'
CHAR(13) - 'Carriage Return'