I have been rewriting some Jquery tasks that I had previously written and want them to now work in my AngularJs App.
I am able to toggle the glyphicons, but how can I change the text and scroll feature as well?
This is my code:
HTML
<body ng-app="toggleApp" ng-controller="toggleCtrl as tc">
<a ng-click="tc.toggle('glyph'); tc.toggle('text')" class="lead p-color learn-button togglebtn shake shake-rotate">
<small>
<span id="toggleGlyph" ng-class="tc.iconGlyph ? 'glyphicon glyphicon-minus' : 'glyphicon glyphicon-plus'">
</span> <span ng-class="tc.textDesc ? 'Hide' : 'Learn More'">Learn More</span>
</small>
</a>
</body>
Main Javascript
var app = angular.module('app', ['ui.bootstrap', 'ngRoute', 'ngAnimate']);
app.config(function($interpolateProvider, $routeProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
$routeProvider
.when('/', {
templateUrl : 'pages/LandingPage.html',
controller : 'LandingCtrl'
})
Controller Javascript
app.controller('toggleCtrl', function () {
this.toggle = function (property) {
this.iconGlyph = (property === 'glyph') ? !this.iconGlyph : this.iconGlyph;
this.textDesc = (property === 'text') ? !this.textDesc : this.textDesc;
}
});
Previous Jquery
$(function () {
$('a.togglebtn').click(function () {
$("#toggleGlyph").toggleClass("glyphicon-minus glyphicon-plus");
$('#toggleText').text($('#toggleText').text() === "Learn More" ? "Hide" : "Learn More");
$('#myContent').stop().slideToggle(500);
$('html,body').animate({ scrollTop: $('#myContent').offset().top - 200 }, 800);
return false;
});
});