R
R
Roma Cockenshtuff2016-03-02 22:53:28
Angular
Roma Cockenshtuff, 2016-03-02 22:53:28

How to fix parse error?

Below in the ng-click directive is a function that takes 2 parameters and angular complains about these parameters:
Syntax Error: Token '{' invalid key at column 16 of the expression [deleteArticle({{article.id}},{{article.user_id}} )] starting at [{article.id}},{{article.user_id}})].
if I write parameters without curly braces, article.id and article.user_id remain in the function parameters when unloading articles

<article ng-repeat="article in articles.data" class="article col-md-12">
        <div class="col-md-6 article-image">
          <a class="rg-transition" href="#/article/{{ article.id }}">
            <img class="img-responsive" src="/media/blog/article_images/{{ article.images }}"/>
          </a>
        </div>
        <div class="col-md-6">
          <a href="#/article/{{ article.id }}">
            <div class="rg-transition article-title">{{ article.title }}</div>
          </a>
          <div class="description-block">
            <div class="article-date information-text">
              <span class="sub-text">Published at: </span>{{ article.published_at }}
            </div>
            <div class="author information-text">
              <span class="sub-text">By: </span>
              <a href="#/search/author/{{ article.user_id }}">{{ article.userName }}</a>
            </div>
            <div class="tags-block">
              <span class="sub-text">Tags:</span>	
              <a ng-repeat="tag in article.tags" class="tag" href="#/search/tag/{{ tag.id }}">
                {{ tag.name }}
              </a>
            </div>
          </div>
          <div class="article-body">{{ article.body | limitTo: '400' }}...</div>
          <div class="article-button">
            <a href="#/article/{{ article.id }}" class="rg-link read-more blog-button rg-transition">Keep reading</a>
          </div>
          
            <div class="article-button">
              <a href="#" class="rg-link edit-the-article blog-button rg-transition">Edit</a>
            </div>
            <div class="article-button">

/////////////////////////////////// ошибка ///////////////////////////////////////////
              <div ng-click="deleteArticle({{article.id}},{{article.user_id}})" class="rg-link del-the-article blog-button rg-transition">Delete</div>
////////////////////////////////////// ошибка  /////////////////////////////////////////////////

            </div>
          
        </div>
        <div class="clear"></div>
        <hr>
      </article>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lega, 2016-03-02
@LesterTheMolester

ng-click="deleteArticle(article.id, article.user_id)"

Артур, 2016-03-02
@astralo

Так уберите оттуда скобки, Они там не нужны вроде как)

Сергей Протько, 2016-03-03
@Fesor

Культ карго. Разберитесь с выражениями в шаблонах, вам не нужна там интерполяция.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question