frankyzf
V2EX  ›  Angular

自定义指令时, scope 选{},为什么要在指令定义时和调用时都要写传递的参数?

  •  
  •   frankyzf · Sep 18, 2016 · 2947 views
    This topic created in 3525 days ago, the information mentioned may be changed or developed.

    如下代码,如果子作用域中有些字段和父作用域有些字段名称一样,为什么也都要写? myModule.directive("myDirective", function(){ return { restrict: "EA", scope: { myName: "@", mySex: "=", getName: "&" }, template: ... ... } })

    <my-directive my-name="{{name}}" my-sex="sex" get-name="say()"></my-directive>

    1 replies    2016-09-18 17:20:18 +08:00
    frankyzf
        1
    frankyzf  
    OP
       Sep 18, 2016
    自顶
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4991 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:45 · PVG 17:45 · LAX 02:45 · JFK 05:45
    ♥ Do have faith in what you're doing.