I am new to angularJS. what I want is , I have some social links icons along with textbox. by default linkedin icon is selected. when I click on facebook icon, then its color should be changed to blue background and also textbox with facebook link should get changed and linkedin background should be as gray as others icons.
How can I achieve using angularjs?
Any help would be great.
Thank You.
app.controller('SocialIconController', function($scope) {
$scope.option = "linkedin";
$scope.social_toggle = false;
});
.exhibitor_social_icon {
background: #d7d6d6;
height: 20px;
width: 20px;
padding: 5px 10px 5px;
margin: 0 3px;
cursor: pointer;
}
.linked_in_bg_color {
background: #0077B5;
width: auto;
border: thin white solid;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div ng-app="">
<div class="form-group margin_top_20" ng-controller="SocialIconController">
<label class="col-md-2 col-sm-2 col-xs-12 control-label set_padding_0">Social Link</label>
<div class="col-md-10 col-sm-10 col-xs-10 set_padding_0">
<span class="exhibitor_social_icon linked_in_bg_color margin_left_0" ng-click="social_toggle = !social_toggle" ng-class="{exhibitor_social_icon : !social_toggle, linked_in_bg_color : social_toggle}">
<i class="fa fa-linkedin text-white"></i>
</span>
<span class="exhibitor_social_icon" ng-click="social_toggle = !social_toggle" ng-class="{exhibitor_social_icon : !social_toggle, linked_in_bg_color : social_toggle}">
<i class="fa fa-facebook text-white" ></i>
</span>
<span class="exhibitor_social_icon">
<i class="fa fa-twitter text-white" ></i>
</span>
<input class="form-control margin_top_4" placeholder="www.linkedin.com/example" type="text" ng-show="!social_toggle">
<input class="form-control margin_top_4" placeholder="www.facebook.com/example" type="text" ng-show="social_toggle">
</div>
</div>
</div>
there are two text boxes by default in the stackoverflow code editor it should be only one by default.
Here is JSFiddle
3
Answers
Try this:
You can put your icons into a list of objects with 2 properties :
Repeat it :
Change the background on click or do some other actions :
Demo
You can change your array :
and use the placeholder for your input
Is this the same that you wanted?
Here is JSFiddle
Hope this helps