Is there a way to not populate HTML with policies?

3

Using the ng-click directive to get a click event on a link would look something like:

<a ng-click="call('home')" href="#" title="ir para homepage">Home</a>

But would not this be the same as using onclick="call('home')" ?

Is not a good practice in web development to separate each document with its proper functionality? Avoiding that lot of CSS and Javascript inline ?

Is it possible, for example, to select an element similar to the known $('foo').on('click', function(){}); i.e can access the element of the JavaScript file and without filling the HTML of policies?

For example:

<a ng-model='abrir' href='#'>Abrir</a>

And in JS:

$scope.abrir.on('click', function(){
   call('foo');
});
    
asked by anonymous 26.11.2014 / 21:49

2 answers

1

ng-click is different from onclick . The Angular directive uses expressions from the framework itself , that is, they are in the context of the Angular scope (which is not directly accessible by onclick ).

And no, there is no Angular method that behaves like jQuery handlers, but you can use it in parallel to execute expressions of the global scope.

    
26.11.2014 / 22:41
1

Angular comes to extend the HTML, at first you can think it is dirty, for me it makes it more declarative, in the model $ ('item'). on ('click', does something); there in the js file, it can be organized for a programmer but for a designer it is hidden because in html there is no reference to the code.

    
27.12.2014 / 16:46