Angular js 从 html 页面 http.get() 数据传递参数时出现语法错误

Syntax Error in Angular js passing parameter from html page http.get() data

我正在尝试从 html 页面传递参数以从数据库中删除一行。 http.get() 方法 return 是所有书籍的数据,我正在传递某本书的 id 以将其删除。 但它的 return 语法错误。

这里是 html 页面,带有删除按钮,在 ng-click 上调用了函数

    <div class="container">

      <table class="table">
        <thead>
          <tr>
            <th>Id</th>
            <th>Name of Book</th>
            <th>Author</th>
            <th>Description</th>
            <th>No of books available</th>
          </tr>
        </thead>

        <tbody>

          <tr ng-repeat = "book in libraryBooks | filter:keyword">
            <td>{{book.id}}</td>
            <td>{{book.name}}</td>
            <td>{{book.author}}</td>
            <td>{{book.description}}</td>
            <td>{{book.count}}</td>

<td><button ng-click = "removeItem({{book.id}})">remove</button></td>
      </tr>

        </tbody>
      </table>
    </div>

这是浏览器控制台中的 returning 语法错误 我将此参数传递给控制器​​接收以调用休眠函数来删除具有该特定 id

的书

你可以通过 book.id

像这样:

<button ng-click = "removeItem(book.id)">remove</button>

因为您不能在 ng-click 指令中使用 {{}} 插值指令,因为您可以直接访问 ng-click 指令中的作用域变量

ng-click="removeItem(book.id)"

ng-click 是 angular 指令。它接受范围内的参数。所以你可以使用下面的行

ng-点击="removeItem(book.id)"