Get the attribute value of the tag dynamically in angularjs directive (you need to bind a changed model)

1.angularjs directive defines a comparison function that gets the incoming value dynamically and calls this method as soon as the input box changes. The
code is as follows:

 .directive("lessThan",[function () {
            return {
                require: "ngModel",
                restrict: "A",
                priority:"9",
                link: function ($scope, element, attrs, ctrl) {

                    var lessThan = function (inputValue) {
                        inputValue = inputValue || "";
                        console.log($scope[attrs.lessThan]);
                        if(attrs.lessThan){
                            if(inputValue>attrs.lessThan){
                                inputValue = ""
                            }
                        }

                        return Number(inputValue);
                    };

                    ctrl.$parsers.unshift(lessThan);

                    lessThan($scope[attrs.ngModel]);

                }
            };
        }])

in html:

<input
        type="text"
        ng-model="hopeCostRate"
        less-than = "{{proposal.hopeRate}}"
        >

problem encountered: proposal.hopeRate is another model, but each change can not get this value, always "", do not know how to solve. Call for help ~

Jun.20,2021
Menu