angular之ng-value指令

前端之家收集整理的这篇文章主要介绍了angular之ng-value指令前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html>
<html>
    <head>
        <Meta charset="UTF-8">
        <title>angular-value</title>
        <script src="js/angular.min.js"></script>
    </head>
    <body>
        <div ng-app="hd" ng-controller="ctrl">
            名称<input type="text" ng-model="goods.name" />
            <br />
            价格:<input type="text" ng-model="goods.price" /> <br />
            数量<input type="text" ng-model="goods.num" /> <br />
            总价:<input type="text" ng-value="goods.num*goods.price" readonly="readonly"/>
        </div>
        <script type="text/javascript"> var m=angular.module('hd',[]); m.controller('ctrl',['$scope',function($scope){ $scope.goods={"name":"apple","price":20,"num":2}; }]) </script>
    </body>
</html>
ng-value 指令用于设置 input 或 select 元素的 value 属性
原文链接:https://www.f2er.com/angularjs/148415.html

猜你在找的Angularjs相关文章