将参数传递给选项卡

时间:2014-08-25 07:11:41

标签: angularjs

我正在构建我的第一个Angular应用程序,其中包含产品规范列表,例如“品牌名称”等。已完成的应用程序将连接到MSSQL数据库。

我有一个包含已保存规格的列表,当我点击其中一个时,我希望发生以下情况:

  1. 显示编辑规范标签
  2. 传递参​​数SpecificationId
  3. 使用当前规范标识
  4. 执行http GET

    我在app的基本状态下设置了一个plunker:

    http://embed.plnkr.co/4F8LMwMorZEF0a42SzTJ/

1 个答案:

答案 0 :(得分:0)

由于你已经发送了你的身份证,你只需要在你的方法中得到它:

像这样更新您的控制器:

app.controller('TabController', function ($scope) { // use $scope here

并在$scope.spec对象中设置ID,如下所示:

this.setTab = function (selectedTab, specId) { // get the id in the args here
     this.tab = selectedTab;
     $scope.spec = {id : specId}; // set the id in here
     console.log($scope.spec.id);
};

然后你可以将标记中的id值绑定为:

The current Specification ID is: <strong>{{spec.id}}</strong>

Updated plunkr demo.

相关问题