zoukankan      html  css  js  c++  java
  • AngularJS 页面计算

    <div ng-app="multipliedCaculateApp" ng-controller="multipliedCaculateController as vm">
        <div class="form-group col-md-4">
            <label><span class="red">*</span>单价(元):</label>
            <input type="text" class="form-control width-60" ng-change="vm.getTotalPrice()"
                   ng-model="vm.editResource.unitPrice"/>
        </div>
        <div class="form-group col-md-4">
            <label><span class="red">*</span>数量:</label>
            <input type="text" class="form-control width-60" ng-change="vm.getTotalPrice()"
                   ng-model="vm.editResource.listingNumber"/>
        </div>
        <div class="form-group col-md-4">
            <label><span class="red">*</span>总价(元):</label>
            <input type="text" disabled ng-model="vm.editResource.totalPrice" 
                   required class="form-control width-60" />
        </div>
    </div>
    
    <script src="~/Scripts/angular.min.js"></script>
    <script>
            var mainApp = angular.module("multipliedCaculateApp", []);
            mainApp.controller('multipliedCaculateController', function ($scope) {
                debugger;
                var vm = this;
                //editResource是个object  可以不给unitPrice和listingNumber赋默认值
                vm.editResource = {
                    unitPrice:1,
                    listingNumber:2
                };
                vm.getTotalPrice = function () {
                    vm.editResource.totalPrice =vm.editResource.unitPrice * vm.editResource.listingNumber;
                }
                vm.getTotalPrice();
            });
    </script>

    学习技术最好的文档就是官方文档,没有之一。
    还有学习资料Microsoft LearnCSharp LearnMy Note
    如果,你认为阅读这篇博客让你有些收获,不妨点击一下右下角的推荐按钮。
    如果,你希望更容易地发现我的新博客,不妨点击一下关注

  • 相关阅读:
    G D 3 2 预 处 理 符 号 配 置 中 定 义
    指针接收函数
    SMT(SF)
    电流高端采样问题
    简单分析一个采集交流电压平均值的电路
    i--和--i的区别
    结构体共用体的使用
    .net Filter 和 代理模式杂谈
    Spring boot 日志 Logback
    spring boot 使用 mongodb
  • 原文地址:https://www.cnblogs.com/Lulus/p/7874103.html
Copyright © 2011-2022 走看看