选择第二个框,Angular时触发事件

时间:2017-07-07 15:26:37

标签: javascript jquery angularjs

我选择父项时有2个方框,第二个选择所选父项的子项。

如何在第二次选择后运行下面的函数?

角度函数

$scope.myFunc = function() {
            var jsonItem = JSON.parse($scope.formData.formatType.id);
            sessionStorage.setItem('format', jsonItem);
        }

HTML

<select ng-model="formData.ProductType.name" ng-change="productTypeChange()" ng-options="product.name as product.name for product in productsandformats">
    <option value="">- Please Choose -</option>
</select>

<select ng-model="formData.formatType" ng-options="format.Fname for format in formats.format" ng-if="formData.ProductType.name">
    <option value="">- Please Choose -</option>
</select>

1 个答案:

答案 0 :(得分:2)

使用ng-change

    <select ng-model="formData.formatType"
            ng-options="format.Fname for format in formats.format"
            ng-if="formData.ProductType.name" ng-change="myFunc()">
        <option value="">- Please Choose -</option>
    </select>`