Javafree
Página Inicial do Fórum > Front-End Web

AngularJS diretivas



Criar novo tópico   Responder tópico
  1. Comment Arrow

    Publicado em: 14/07/2015 11:54:25

    Qual a melhor maneira de utilizar diretivas do angularJS?

    Pergunto isso por que, me deparei com uma tela (CRUD) em que diretivas são usadas para todos os campos (sem função alguma especial, por exemplo validações).

    exemplo: Uma tela de cadastro de produto (código, descrição, valor e quantidade), para cada um desses campos foi criada uma diretiva utilizando como template inputs e labels, sendo rescritas tambem diretivas nativas do angular como ng-model e ng-change, que na pratica fazem a mesma coisa das nativas, isso é correto?
    _________________

    GRADUANDO EM ENGENHARIA DA COMPUTAÇÃO
    UNIUBE - UNIVERSIDADE DE UBERABA



  1. jackpeppin
    Posts:1


    Comment Arrow

    Publicado em: 06/10/2015 10:03:39

    Angular has some features that can break certain CSP (Content Security Policy) rules.

    If you intend to implement these rules then you must tell Angular not to use these features.

    This is necessary when developing things like Google Chrome Extensions or Universal Windows Apps.

    The following rules affect Angular:

    unsafe-eval: this rule forbids apps to use eval or Function(string) generated functions (among other things). Angular makes use of this in the $parse service to provide a 30% increase in the speed of evaluating Angular expressions.

    unsafe-inline: this rule forbids apps from inject custom styles into the document. Angular makes use of this to include some CSS rules (e.g. ngCloak and ngHide). To make these directives work when a CSP rule is blocking inline styles, you must link to the angular-csp.css in your HTML manually.

    If you do not provide ngCsp then Angular tries to autodetect if CSP is blocking unsafe-eval and automatically deactivates this feature in the $parse service. This autodetection, however, triggers a CSP error to be logged in the console:

    Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of
    script in the following Content Security Policy directive: "default-src 'self'". Note that
    'script-src' was not explicitly set, so 'default-src' is used as a fallback.
    This error is harmless but annoying. To prevent the error from showing up, put the ngCsp directive on an element of the HTML document that appears before the <script> tag that loads the angular.js file.

    http://www.besanttechnologies.com/training-courses/web-designing-training || http://www.webdesigningtraininginchennai.in/



  1. Relacionados