Я пробовал всеми способами (сохраняя область видимости false и т. д., но не имея возможности изменить область действия в контроллере), я что-то упустил.
директива:
angular.module("ui.materialize.inputfield", [])
.directive('inputField', ["$timeout", function ($timeout) {
return {
transclude: true,
scope: {},
link: function (scope, element) {
$timeout(function () {
Materialize.updateTextFields();
// The "> > [selector]", is to restrict to only those tags that are direct children of the directive element. Otherwise we might hit to many elements with the selectors.
// Triggering autoresize of the textareas.
element.find("> > .materialize-textarea").each(function () {
var that = $(this);
that.addClass("materialize-textarea");
that.trigger("autoresize");
var model = that.attr("ng-model");
if (model) {
scope.$parent.$watch(model, function (a, b) {
if (a !== b) {
$timeout(function () {
that.trigger("autoresize");
});
}
});
}
});
// Adding char-counters.
element.find('> > .materialize-textarea, > > input').each(function (index, countable) {
countable = angular.element(countable);
if (!countable.siblings('span[class="character-counter"]').length) {
countable.characterCounter();
}
});
});
},
template: '<div ng-transclude class="input-field"></div>'
};
}]);
а вот мой взгляд
<div ng-controller="Example Controller"
<div input-field class="col l3">
<input type="text" ng-model="class1" length="150">
<label>Class</label>
{{class1}}
</div>
{{class1}}
</div>
Я вижу, что меняется только class1 области действия директивы, но не последний class1,
если я инициализирую свой контроллер с помощью $scope.class1 = 9, меняется только первый class1, но не второй class1. Может ли кто-нибудь помочь мне в решении проблемы