Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Few questions about directives
Message
De
07/03/2015 04:31:14
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01615790
Message ID:
01616390
Vues:
50
This message has been marked as a message which has helped to the initial question of the thread.
>>>Viv,
>>>
>>>When you were testing smNumberFormat directive, do you have your test page, etc.?
>>>
>>>Can you expand that sample plnkr I created?
>>>
>>>http://plnkr.co/edit/HBmOKTqQ9p4m3PzHNvds?p=preview
>>>
>>>
>>>
>>>Thanks in advance.
>>>
>>>Apparently other people are having similar problem, see https://github.com/angular/angular.js/issues/11157#issuecomment-75706528
>>
>>Not sure what you're asking here. Are you trying to use your smNumberFormat directive within a ng-repeat ?
>
>Yes. That was the markup:

>Please note, that I had to switch into input type="text" otherwise I was getting that obscure error someone is also getting. I'm wondering if it's possible to reproduce with the plnkr I started. I don't know how to add these 2 directives although I think I tried removing both directives and only leaving input type="number" and still getting that error.
>
>In the other similar page I don't get that same error, so it's really hard to reproduce.

And thus impossible to know what the problem is. There's certainly no intrinsic problem when using the 'type=number' in conjunction with your smNumberFormat directive (using pre-link) within a ng-repeat. In fact, in that scenario using min=0 means you don't need the negative-amount validation.

This works for me (I can only suggest you add any other functionality bit by bit to determine the cause of the error.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="Content/bootstrap.css" rel="stylesheet" />
</head>
<body>
    <div ng-app="theApp">
        <div ng-controller="theController">
            <table>
                <tbody>
                    <tr ng-repeat="result in payInvoices" ng-form="payInvoicesRow">
                        <td>
                            <div class="input-group">
                                <input type="number" name="payment" ng-model="result.payment" id="payment"
                                       min=0 max="100" sm:number-format data-accuracy="2"
                                       data-sm:number placeholder=" 000.00" class="form-control" />
                            </div>
                            <div class="field-validation-error">
                                <span ng-show="payInvoicesRow.payment.$error.min">Must be positive</span>
                            </div>
                        </td>
                    </tr>
                </tbody>
             </table>
        </div>
    </div>
    <script src="Scripts/angular.js"></script>
    <script type="text/javascript">
        var theApp = angular.module("theApp", [])
            .controller("theController", function ($scope) {
                $scope.payInvoices = [
                     { isToBePaid: true, invoice_No: 1, descrip: "Test Invoice 1", payment: 10 },
                     { isToBePaid: false, invoice_No: 2, descrip: "Test Invoice 2", payment: 0 },
                     { isToBePaid: false, invoice_No: 3, descrip: "Test Invoice 3", payment: 7 },
                     { isToBePaid: true, invoice_No: 4, descrip: "Test Invoice 4", payment: 1000 },
                ];
            })
    </script>
</body>
</html>
(Your directive omitted for brevity)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform