将范围添加到指令AngularJS时无法提交表单

时间:2015-09-21 12:38:08

标签: javascript angularjs

当我移除范围时,每个工作正常......

这是我的指示:

function addcomment(commentFactory)
{
    //CREATING BUTTON FOR COMMENT AND CALL LINK FUNCTION
    var addComment = {
        link: link,
        restrict: "E",
        scope: {
            valid: '='
        },
        template: '<input type="submit" ng-disabled="valid" class="btn btn-default pull-right" value="Send" />'
    };
....

这是HTML:

<form name="mainComment" ng-submit='addComment(param)' class="dd animated slideInDown" novalidate>
        <div class="form-group">
            <text-angular name="mainTxt" required ta-max-text="600" ta-min-text="15" ng-model="form.comment"></text-angular>

            <span style="color:red" ng-show="mainComment.mainTxt.$dirty && mainComment.mainTxt.$invalid">
                <span ng-show="mainComment.mainTxt.$error.required">Thread content is required.</span>
            </span>
            <p style="color:red" ng-show="mainComment.mainTxt.$error.taMaxText">Text should be at last 15 characters.</p>
            <p style="color:red" ng-show="mainComment.mainTxt.$error.taMinText">Text should not be more then 15 characters.</p>
        </div>
            <!--DIRECTIVE FOR SUBMIT BUTTON AND CLIENT CONTENT APPEND-->
            <addcomment valid="mainComment.mainTxt.$invalid"></addcomment>

    </form>

0 个答案:

没有答案