Input autofocus attribute

后端 未结 10 1553
Happy的楠姐
Happy的楠姐 2020-11-30 04:47

I have places in my code where I have this:


I would like to be able to use it like

10条回答
  •  孤街浪徒
    2020-11-30 05:25

    You can do this with the built-in ngAttr attribute bindings.

    
    

    The autofocus attribute will be added if SOME_SCOPE_VARIABLE is defined (even if it's false), and will be removed if it's undefined. So I force falsy values to be undefined.

    $scope.SOME_SCOPE_VARIABLE = someVar || undefined;
    

提交回复
热议问题