Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
inline Javascript to Angular Directive on View
Rp Singh
Dec 20 2017 11:23 PM
118
Reply
Hi,
I have following javascript code:
$(document).on(
'click'
,
'.panel-heading span.clickable'
,
function
(e) {
var
$
this
= $(
this
);
if
(!$
this
.hasClass(
'panel-collapsed'
)) {
$
this
.parents(
'.panel'
).find(
'.panel-body'
).slideUp();
$
this
.addClass(
'panel-collapsed'
);
$
this
.find(
'i'
).removeClass(
'glyphicon-chevron-up'
).addClass(
'glyphicon-chevron-down'
);
}
else
{
$
this
.parents(
'.panel'
).find(
'.panel-body'
).slideDown();
$
this
.removeClass(
'panel-collapsed'
);
$
this
.find(
'i'
).removeClass(
'glyphicon-chevron-down'
).addClass(
'glyphicon-chevron-up'
);
}
})
and html as:
<
div
class
=
"col-100"
>
<
div
class
=
"panel panel-danger"
>
<
div
class
=
"panel-heading"
style
=
"background:#cc0000"
>
<
h3
class
=
"panel-title"
style
=
"color: white"
>
Heading Pabel
<
span
class
=
"pull-right clickable"
>
<
i
class
=
"glyphicon glyphicon-chevron-down"
>
</
i
>
</
span
>
</
h3
>
</
div
>
<
div
class
=
"panel-body"
style
=
"display:none;"
>
Body of panel
</
div
>
Please help in creating directive and how to use it on html page.
The directive has to be saved on separate .js file.
Any help would be highly appriciable.
Thanks,
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
asp.net mvc video gallery & player
Swap Records Present in textbox