How to tie in one direction at an angle and tie again when changing the model?

Is there any solution or angular plugin to bind one way and bind again when the model is changed? Now I use the bind-once plugin , but it just binds for the first time and then destroys the observer. Example:

    <div bindonce="model"><span bo-bind="model.title"></span></div>
+4
source share
2 answers

Angular is already doing this for you

<div><span ng-bind="model.title"></span></div>

or

<div><span>{{model.title}}</span></div>
+3
source

: re-redner (ng-if) . , dom , : angular , bind-once, .

- DOM, .

( ):

csapp.directive("csReloadOn", ["$timeout", "Logger", function ($timeout, logManager) {

    var $log = logManager.getInstance("csReloadOn");

    var getTemplate = function () {
        return '<div ng-if="doRefreshPageOnModeChange"><div ng-transclude=""></div></div>';
    };

    var linkFunction = function (scope, element, attrs) {
        scope.doRefreshPageOnModeChange = true;

        scope.$watch(attrs.csReloadOn, function (newVal, oldVal) {
            if (newVal === oldVal) return;
            $log.info("changed mode from : " + oldVal + ", to : " + newVal);
            scope.doRefreshPageOnModeChange = false;
            $timeout(function () { scope.doRefreshPageOnModeChange = true; }, 100);
        });
    };

    return {
        restrict: 'A',
        transclude: true,
        template: getTemplate,
        link: linkFunction
    };
}]);
0

All Articles