小编Sha*_*han的帖子

如果值大于255,如何使用angluarJS禁用按钮?

如果textarea包含超过255个字母,我想使用angularJS来禁用提交按钮.我通常不使用angularJS,所以我真的不知道怎么做.这就是我所拥有的:(HTML)

<tr>
    <td colspan="2" align="center">
        <textarea rows="5" cols="40" name="Messge" ng-model="message"></textarea>
    </td>
</tr>
<tr>
    <td align="center">Number of letters left: <span ng-bind="left()"></span>
    </td>
</tr>
<tr>
    <td align="center" colspan="2">
        <input type="submit" value="submit" ng-disabled="error" />
    </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

现在这里是javascript文件代码:

angular.module('myApp', []).controller('userCtrl', function ($scope) {
    $scope.messge = '';
    $scope.error = false;
    $scope.incomplete = false;

    $scope.$watch('messge', function () { $scope.test(); });

    $scope.test = function () {
        if ($scope.messge.length > 255) {
            $scope.error = true;
        } else {
            $scope.error = false;
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

第二档:

app.controller("myNoteCtrl", function ($scope) …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs

3
推荐指数
1
解决办法
1390
查看次数

将二维 int 数组转换为字节数组


我想将二维 int 数组转换为字节数组。最简单的方法是什么?
例子:

int[,] array = new int[2, 2] { { 2, 1 }, { 0, 1 } };
Run Code Online (Sandbox Code Playgroud)

我怎样才能转换array为a byte[]?在您的答案中,请同时包含与之相反的函数。(如果有一个函数可以将 an 转换int[,]为 a byte[],请告诉我如何将 a 转换byte[]为 an int[,]
如果您问自己为什么我需要这样做:我需要通过int[,]TCP 客户端将 a 发送到服务器,那么向客户端发送响应
PS:我考虑创建一个[Serializeable]类,其中包含int[,],然后将该类序列化为一个文件并发送该文件,在服务器端我将反序列化该文件并从那里获取数组。但我认为这需要更多的资源才能做到这一点,然后将其转换为byte[].
感谢您的帮助!:)

c# arrays byte type-conversion

-2
推荐指数
1
解决办法
2909
查看次数

标签 统计

angularjs ×1

arrays ×1

byte ×1

c# ×1

html ×1

javascript ×1

type-conversion ×1