Which are the core directives of AngularJS?

Following are the three core directives of AngularJS.

  • ng-app − This directive defines and links an AngularJS application to HTML.
  • ng-model − This directive binds the values of AngularJS application data to HTML input controls.
  • ng-bind − This directive binds the AngularJS Application data to HTML tags.
Advertisements

What are the disadvantages of AngularJS?

Following are the disadvantages of AngularJS.

  • Not Secure − Being JavaScript only framework, application written in AngularJS are not safe. Server side authentication and authorization is must to keep an application secure.
  • Not degradable − If your application user disables JavaScript then user will just see the basic page and nothing more.

What are the advantages of AngularJS?

Following are the advantages of AngularJS.

  • AngularJS provides capability to create Single Page Application in a very clean and maintainable way.
  • AngularJS provides data binding capability to HTML thus giving user a rich and responsive experience.
  • AngularJS code is unit testable.
  • AngularJS uses dependency injection and make use of separation of concerns.
  • AngularJS provides reusable components.
  • With AngularJS, developer writes less code and gets more functionality.
  • In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing.
  • AngularJS applications can run on all major browsers and smart phones including Android and iOS based phones/tablets.

 

What are disadvantages of using JavaScript?

We can not treat JavaScript as a full fledged programming language. It lacks the following important features −

  • Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.
  • JavaScript can not be used for Networking applications because there is no such support available.
  • JavaScript doesn’t have any multithreading or multiprocess capabilities.

What are the advantages of using JavaScript?

Following are the advantages of using JavaScript −

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

    javascript

Explain how this works in JavaScript

this is the context the code is running in

However, the context seems to change a lot, and I find it rather confusing. So I signed up for an email series on how this can change. Here’s a sweeping overview of that series:

  • this refers to the window

At its simplest, this is the window itself without anything fancy going on. You can call this in the console directly and get Window.

  • this refers to the object it’s being called from
function currentYear() {
  return 2014;
}
var person = { birthYear: 1977,
               getAge: function() {
                 return currentYear() - this.birthYear;
               }
             };
person.getAge();
// returns 37

You can see the call to this.birthYear in the getAge function references the person’s birthYear. That is the this refers to its parent object. As a Ruby developer this is similar to self.

  • this refers to the element the event is bound to
$('a').on('click', function(event) {
  console.log(event.target === this); // logs true
});


Here the this refers to the link the user clicked on, just like event.target

  • this refers to the context that was explicitly set

Apparently you can use call or apply and pass a context explicitly. In that case this refers to the passed context.

function greeter(){
  return 'Hello ' + this.name + '!';
}

var passableContext = { name: 'world' };
greeter.call(passableContext)
// returns 'Hello world!'