Answer the question
In order to leave comments, you need to log in
How to use js plugin in angularjs?
There is a view
<div id="vl-global">
<div id="ng-container" ng-view ></div>
</div>
.directive('myDatepicker', function() {
return {
require: 'ngModel',
link: function (scope, element, attrs, slideShowCtrl) {
$(function(){
$(".element").typed({
strings: ["First sentence.", "Second sentence."],
typeSpeed: 0
});
});
}
}
}),
.controller('updateController',['$scope',function($scope){
$scope.updates = ['This is update 1',
'This is the second update!'];
$(function(){
$(".update-box p").typed({
strings:$scope.updates,
typeSpeed: 40,
loop: true,
backDelay: 1500,
contentType: 'text',
loopCount: false,
cursorChar: " |"
});
});
}]);
Answer the question
In order to leave comments, you need to log in
Check if these elements exist in the dom before you add a plugin to them.
in simple terms:
If not:
A bad and crutch solution would be to wait for these elements to appear:
.directive('myDatepicker', function() {
return {
require: 'ngModel',
link: function (scope, element, attrs, slideShowCtrl) {
setTimeout(function() {
$(".element").typed({
strings: ["First sentence.", "Second sentence."],
typeSpeed: 0
});
});
}
}
}),
.directive('wysiwygComponent', function() {
return {
templateUrl: 'template/partials/wysiwygComponent.html',
restrict: 'A',
link: function(scope, element, attrs) {
/** Инициализируем редактор кода после появления директивы **/
var txt = $(element).find("textarea");
txt.wysihtml5({
locale: "ru-RU",
toolbar: {
"html" : true,
},
stylesheets: [],
events: {
"blur": function() {
scope.$apply(function() {
var html = txt.siblings("iframe").contents().find("body").html();
scope.modelModel = html;
});
}
}
});
/** следим за изменением содержимого в редакторе **/
scope.$watch('modelModel', function(val) {
txt.siblings("iframe").contents().find("body").html(val);
});
},
scope: {
label:'@',
modelModel:'='
}
};
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question