我的AngularJs版本是v1.4.3
,在做表单验证时,遇到了问题。
我希望达到的效果是:当表单内容为空时,登录按钮禁用。但现在是登录按钮没有被禁用。
var app=angular.module("ayApp",[]); app.controller("ayAppCtrl",['$scope',function($scope){ var vm=$scope.vm={}; vm.d=storedb('ay').find(); vm.submit=function(sign_form){ sign_form.$setDirty(); if(sign_form.$valid){ alert("Success"); } } }]);
A vm object is bound to the scope, and then you create a vm. What do you want to do?
Secondly, I don’t think you need to write a controller yourself to implement this function.