M
M
Maxim Ivanov2016-10-19 23:29:50
Angular
Maxim Ivanov, 2016-10-19 23:29:50

How to dynamically insert data into a component?

I understand that jQuery is not cool and I would like to get rid of this

$('.maintext').html($compile(
        `
        <div>${description}
        <a class="greenbtn createbtn waves-effect waves-light btn" 
            ng-click="processCreate(${id})">
            ${btnCreatText}
        </a></div>
        `
      )($scope)
    );

Accordingly, I should have something similar to this in the code:
<div>
    <create />
</div>

And the component itself will be like this:
<div>
        /* тут как-то встает описание */
        <a class="greenbtn createbtn waves-effect waves-light btn" ng-click="processCreate(/* передаем id*/)">
            Создать
        </a>
</div>

But I can't figure out how to start rendering the create component if not directly accessed via $('.maintext'). And how can the component get new states, each time the conditional link is clicked, the same id for the processCreate function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Frozen Coder, 2016-10-20
@splincodewd

Google for directives. I understand that this is what you need if you are on Angular.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question