Blog 4 IT beginner to copy and run it : AngularJS, JAVA, C#, JQuery, BootStrap, WPF, WebService, Asp.net, Ajax.net
Saturday, 8 August 2015
Wednesday, 6 May 2015
Angularjs cross domain Access configuration
$http.defaults.useXDomain
= true;
$http.defaults.headers.put = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE,
OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type,
X-Requested-With'
};
$http.defaults.headers.post["Content-Type"]
= "application/x-www-form-urlencoded";
Thursday, 30 April 2015
AngularJS - How to repeat multiple table rows / any group of HTML element
<tr ng-repeat-start="user in users">
<td rowspan=2>{{user.id}}</td>
<td colspan=2>{{user.name}}</td>
</tr>
<tr ng-repeat-end>
<td>{{user.email}}</td>
<td>{{user.phone}}</td>
</tr>
Saturday, 25 April 2015
Angularjs difference between Services,Factories & Providers
Services
Syntax:
Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words
module.service( 'serviceName', function );
Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words
new FunctionYouPassedToService()
.Factories
Syntax:
Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.
module.factory( 'factoryName', function );
Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.
Providers
Syntax:
Result: When declaring providerName as an injectable argument you will be provided with
module.provider( 'providerName', function );
Result: When declaring providerName as an injectable argument you will be provided with
ProviderFunction().$get()
. The constructor function is instantiated before the $get method is called - ProviderFunction is the function reference passed to module.provider.
Providers have the advantage that they can be configured during the module configuration phase.
See Example : http://jsbin.com/ohamub/1/edit
Tuesday, 21 April 2015
AngularJS Http Interceptor Example
- under the routing configuration
$httpProvider.interceptors
.push(['$q', '$injector', function ($q, $injector) {
return function (promise) {
return promise.then(function (response) {
return response;
}, function (response) {
if (response.status === 401) {
$injector.get('$state').go('login');
} else if (response.status === 403) {
$injector.get('$state').go('resources');
} else if (response.status === 404) {
$injector.get('$state').go('login');
}
return $q.reject(response);
});
};
}]);
Monday, 20 April 2015
AngularJs Embaded CSS to Html Tag by ng-style
ng-Style will be help to do this
<a ng-style="{ 'background-color' : color, 'background' : color}">
</a>
here color is $scope / $rootScope variable
<a ng-style="{ 'background-color' : color, 'background' : color}">
</a>
here color is $scope / $rootScope variable
Tuesday, 14 April 2015
How do i change user in eclipse svn repository
- open run type %APPDATA%\Subversion\auth\svn.simple
- this will open svn.simple folder
- you will find a file e.g. Big Alpha Numeric file
- Delete that file.
- restart eclipse.
- Try to edit file from projct and commit it
- you can see dialog asking userName password
Difference between $http, $resource & Restangular
$http - $http is built into Angular, so there’s no need for the extra overhead of loading in an external dependency. $http is good for quick retrieval of server-side data that doesn't really need any specific structure or complex behaviours. It’s probably best injected directly into your controllers for simplicity’s sake.
$resource - $resouce is good for situations that are slightly more complex than $http. It’s good when you have pretty structured data, but you plan to do most of your crunching, relationships, and other operations on the server side before delivering the API response. $resource doesn't let you do much once you get the data into your JavaScript app, so you should deliver it to the app in its final state and make more REST calls when you need to manipulate or look at it from a different angle. Any custom behaviour on the client side will need a lot of boilerplate.
Restangular - Restangular is a perfect option for complex operations on the client side. It lets you easily attach custom behaviours and interact with your data in much the same way as other model paradigms you've used in the past. It’s promise-based, clean, and feature-rich. However, it might be overkill if your needs are basic, and it carries along with it any extra implications that come with bringing in additional third-party dependencies.
To Get More Info and example
Friday, 13 February 2015
Date Calculation : Java to get date before or after some days from today
Calendar cNow = Calendar.getInstance();
Date dNow = cNow.getTime();
cNow.add(Calendar.DATE, Day);
Date beforeDate = cNow.getTime();
SimpleDateFormat format =
new SimpleDateFormat("MMM dd, yyyy hh:mm:ss
a");
String dateNow = format.format(dNow);
String dayBefore = format.format(beforeDate);
System.out.println(dateNow);
System.out.println(dayBefore);
________________________________________________
Day is a integer value either in + or - base on requirement
- Day will give you past date
+ Day will give you future date
Thursday, 12 February 2015
Call Rest service from JAVA Core, Post method
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
public class SubscriberService {
public void sendPost() throws Exception {
try {
DefaultHttpClient
httpClient = new DefaultHttpClient();
HttpPost
postRequest = new HttpPost("api url");
StringEntity
input = new StringEntity(
"{"
+
"\"object\":\"value\""
+
"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse
response = httpClient.execute(postRequest);
BufferedReader
br = new BufferedReader(new InputStreamReader(
(response.getEntity().getContent())));
String
output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
httpClient.getConnectionManager().shutdown();
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
Wednesday, 4 February 2015
Could not load file or assembly or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
I was able to fix this error by
Now Try To Publish it will work
- finding the assembly DLL in Windows Explorer,
- right clicking,
- choosing Properties
- pressing the "unblock" button.
Now Try To Publish it will work
Wednesday, 14 January 2015
Asp.net HttpClient POST Method call API
string response = null;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(BASE_URL);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("param1", value1),
new KeyValuePair<string, string>("param2", value2),
});
var result = client.PostAsync(API_URL, content).Result;
response =
result.Content.ReadAsStringAsync().Result;
}
here BASE_URL is some thing like www.mastermoin.com
and API_URL is looking like /api/helloservice
Subscribe to:
Posts (Atom)