Powered by Blogger.
Showing posts with label Angularjs. Show all posts
Showing posts with label Angularjs. Show all posts

Friday, 16 September 2016

Java Questions

Can we override static method?
No, we can't override the static method because they are the part of class not object and it is bound with class whereas instance method is bound with object and static gets memory in class area and instance gets memory in heap.

Can we override the overloaded method?
Yes.

Can we define private and protected modifiers for variables in interfaces?

No, they are implicitly public.

Static Import:

The static import feature of Java 5 facilitate the java programmer to access any static member of a class directly. There is no need to qualify it by the class name.
Advantage of static import:

Less coding is required if you have access any static member of a class oftenly.
Disadvantage of static import:

If you overuse the static import feature, it makes the program unreadable and unmaintainable.


All wrapper classes in java.lang are immutable, i.e. String, Integer, Boolean, Character, Byte, Short, Long, Float, Double, BigDecimal, BigInteger


Wednesday, 4 March 2015

Angualr Question

why ng-bind is better than {{}} in angular?
  • The {{}} is much slower.
  • you might see the actual Hello, {{user.name}} for a second before user.name is resolved (before the data is loaded)
  • in case of {{}}whole text "Hello, {{user.name}}" enclosed by < div > will be copied and stored in memory . but ng-bind will only stored the value of variable in memory , angular will register a watcher where the watch expression consists of the variable only.
  • The brackets on the other hand will be dirty checked and refreshed in every $digest, even if it's not necessary.
  • This ng-bind is a directive and will place a watcher on the passed variable. So the ng-bind will only apply, when the passed value does actually change.
Example:-
<div>  Hello, {{user.name}}</span></div>
<div>  Hello, <span ng-bind="user.name"></span></div>

if you write like below then , you will find person is undefined(in older version of Angular).
<li ng-repeat="person in people">
  Hello, {{calculateTotalPoints(person)}}
</li>

 You have to write:
<li ng-repeat="person in people">
  Hello, <span ng-bind="calculateTotalPoints(person)"></span>
</li>

In the controller, you can define the function:
$scope.calcualteTotalPoints = function(person){
     ....
};


Sunday, 11 January 2015

Angularjs

How to reverse string in angular js

<div ng-controller="secondController">
        <input type="text" ng-model="data.message">
        <h1>{{data.message | toCaps | reverse }}</h1>
</div>
Update to UPPERCASE
myApp.filter('toCaps',function () {
    return function (msg) {
        return msg.toUpperCase();
    }
});
UPDATE to reverse
myApp.filter('reverse',function () {
    return function (msg) {
        return msg.split("").reverse().join("");
    }
});


Tuesday, 16 December 2014

angualar js

Adding watermark
<input type="text" ng-model="car.plate" placeholder="What's the plate?" />


Disable button till all mandatory field is filled
<input type="text" ng-model="car.plate" placeholder="What's the plate?" />
<input type="text" ng-model="car.model" placeholder="What's the Model" />

<button ng-click="park(car)" ng-disabled="!car.plate || !car.model">Park</button>

Recent Articles

© 2014 Learning Java. WP themonic converted by Bloggertheme9. Published By Gooyaabi Templates
TOP