Skip to content

read-more doesn't watch for changes in model #2

@lnramirez

Description

@lnramirez

My model is set to a select

<!-- html -->
<md-select ng-model-options="{trackBy: '$value.id'}" placeholder="Select"
           ng-model="vm.selected">
  <md-option ng-value="case" ng-repeat="item in items" ng-selected="$first">{{item.subject}} - {{item.desc}}</md-option>
</md-select>
<p read-more ng-model="vm.selected.desc" length="50"></p>

Value changes accordingly but since showLinks is set upon controller initialization if first selected valued doesn't compute that requires showLinks then they are never added.

            <!-- read-more/js/directives/readmore.js -->
            if (!$scope.countingWords && $scope.text.length > $attrs.length) {
                $scope.showLinks = true;
            } else if ($scope.countingWords && $scope.text.split(" ").length > $attrs.length) {
                $scope.showLinks = true;
            } else {
                $scope.showLinks = false;
            }

By the same token if the first selected value would require to show links when selecting to one that doesn't it would still show the link. It requires to watch the change on the model too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions