JavaScript Applying one-time bindings to custom element directive

I've got a simple directive—<call-card>—and I'm wondering how to apply one-time bindings to it, as practice to optimize future directives.

This directive's definition object looks like:

{
    restrict: 'E',
    controllerAs: 'callCard',
    scope: {
        headline: '=',
        subtitle: '=?',
        highPriority: '=?',
        onFilterClick: '='
    }
}

And its template:

<div class="headline"
     ng-class="{ 'high-priority': !!callCard.highPriority }">
     {{ callCard.headline }}
</div>
<div class="subtitle"
     ng-if="callCard.subtitle">
     {{ callCard.subtitle }}
</div>
<div class="filter"
     ng-click="callCard.onFilterClick()">
</div>

It's used like:

<call-card ng-repeat="row in cardList.rows"
           headline="row.headline"
           subtitle="row.subtitle"
           on-filter-click="cardList._.bind(cardList.onFilterRowClick, cardList, row)"></call-card>

The collection cardList.rows may change in cardList, but the properties that get passed into <call-card> directive will never change after the <call-card> is created.

Given this scenario, should I change the bindings passed into <call-card>, the bindings in the <call-card> template, or both?

For example—changing the bindings passed into <call-card>:

<call-card ng-repeat="row in ::cardList.rows"
           headline="::row.headline"
           subtitle="::row.subtitle"
           on-filter-click="::cardList._.bind(cardList.onFilterRowClick, cardList, row)"></call-card>       

For example—changing the bindings in the <call-card> template:

<div class="headline"
     ng-class="{ 'high-priority': !!::callCard.highPriority }">
     {{ ::callCard.headline }}
</div>
<div class="subtitle"
     ng-if="::callCard.subtitle">
     {{ ::callCard.subtitle }}
</div>
<div class="filter"
     ng-click="::callCard.onFilterClick()">
</div>

Any help would be appreciated!

Answer:1

I have seen lot of example here.But here am facing another problem that the event is not even detected (button in appended div). Am adding some text-box and a button using append method on a button ...

I have seen lot of example here.But here am facing another problem that the event is not even detected (button in appended div). Am adding some text-box and a button using append method on a button ...

I have written a function which generates an array with 10 randomly generated unique Values. I would like to extend it such that certain values are not included. This is my code: let excludedValues ...

I have written a function which generates an array with 10 randomly generated unique Values. I would like to extend it such that certain values are not included. This is my code: let excludedValues ...

  1. exclude certain values from pivot table
  2. exclude certain values in r
  3. exclude certain values in sql
  4. exclude certain values in excel
  5. exclude certain values in tableau
  6. exclude certain values in average
  7. spss exclude certain values
  8. splunk exclude certain values
  9. tableau exclude certain values from filter
  10. oracle exclude certain values
  11. exclude rows with certain values pandas
  12. exclude rows with certain values r
  13. excel chart exclude certain values
  14. sql select exclude certain values
  15. how to exclude certain values in jmp
  16. how to exclude certain values in access query
  17. qlik sense exclude certain values
  18. how to exclude certain values in qlikview
  19. exclude rows with certain values excel
  20. sql query exclude certain values

How to configure IntelliSense in Visual Studio Code? For example, lets consider the below code snippet. 'use strict'; import React from 'react'; import ReactDOMServer from 'react-dom/server'; I ...

How to configure IntelliSense in Visual Studio Code? For example, lets consider the below code snippet. 'use strict'; import React from 'react'; import ReactDOMServer from 'react-dom/server'; I ...

  1. configure intellisense visual studio code c++
  2. configure intellisense visual studio
  3. configure intellisense visual studio code
  4. enable intellisense visual studio 2017
  5. enable intellisense visual studio
  6. enable intellisense visual studio code
  7. enable intellisense visual studio 2019
  8. enable intellisense visual studio 2015
  9. enable intellisense visual studio 2013
  10. enable intellisense visual studio 2012
  11. enable intellisense visual studio javascript
  12. intellisense settings visual studio
  13. intellisense settings visual studio 2017
  14. intellisense settings visual studio 2019

When you click the link apply any CSS animation during show/hide toggle. The toggle works, but animation is not applied. $('.working-hours-link').click(function(e) { $(this).siblings(".hours")....

When you click the link apply any CSS animation during show/hide toggle. The toggle works, but animation is not applied. $('.working-hours-link').click(function(e) { $(this).siblings(".hours")....

  1. transition doesn't work
  2. transition doesn't work with height auto
  3. transition doesn't work in firefox
  4. transition doesn't work in safari
  5. transition doesn't work in ie
  6. transition doesn't work javascript
  7. transition doesn't work html
  8. does not transition
  9. vue transition doesn't work
  10. css transition doesn't work first time
  11. transition delay doesn't work
  12. transition opacity doesn't work
  13. transition width doesn't work
  14. css transition doesn't ease out
  15. css transition doesn't work in chrome
  16. css transition doesn't work react
  17. transition height doesn't work
  18. hover transition doesn't work
  19. transition background doesn't work
  20. d3 transition doesn't work