我正在研究角度bootstrapUI手风琴,我需要捕捉每个部分的切换事件,例如,在每个部分的标题中,我有一个箭头,当它打开时箭头向下会显示,和其他其他部分的箭头将显示向右箭头。这样的东西:
<accordion-group is-open="true" ng-repeat="destination in mileage.destionations">
<accordion-heading>
<span ng-class="{'fa-chevron-down': openEvent, 'fa-chevron-right': !openEvent">Toggle Me</span>
</accordion-heading>
<div class='accordion-section'>
Main content here
</div>
</accordion-group>
如您所见,如何为手风琴组中的每个部分切换fa-chevron-down和fa-chevron-right类?
答案 0 :(得分:4)
你真的很亲密......
将您的//
// ViewController.m
// REST
//
// Created by Grant Zukel on 8/5/15.
// Copyright © 2015 Grant Zukel. All rights reserved.
//
#import "ViewController.h"
@import GoogleMaps;
@interface ViewController ()
{
}
@end
@implementation ViewController{
GMSMapView *mapView_;
@public NSInteger int_lat;
@public NSInteger int_lon;
}
- (IBAction)drawMap;
{
NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:8001/test/39.748922&-104.986147"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
{
if (data.length > 0 && connectionError == nil)
{
NSDictionary *greeting = [NSJSONSerialization JSONObjectWithData:data
options:0
error:NULL];
//NSLog([greeting objectForKey:@"status"]);
self.greetingContent.text = [greeting objectForKey:@"content"];
self.greetingId.text = [greeting objectForKey:@"id"];
NSString *latitude = ([[greeting objectForKey:@"coords"] objectForKey:@"latitude"]);
NSString *longitude = ([[greeting objectForKey:@"coords"] objectForKey:@"longitude"]);
self.testLat.text = latitude;
self.testLon.text = longitude;
int_lat = [latitude intValue];
int_lon = [longitude intValue];
}
}];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:int_lat
longitude:int_lon
zoom:1];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(int_lat, int_lon);
marker.title = @"Test";
marker.snippet = @"Test";
marker.map = mapView_;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self drawMap];
//NSString *temperatureString = [self getStringForTemperature:A base:B];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
更改为属性名称,而不是值。其他人看起来is-open
始终处于打开状态(is-open
)。
所以这样:
true
现在,当开放<accordion-group is-open="isOpen" ng-repeat="destination in mileage.destionations">
<accordion-heading>
<span ng-class="{'fa-chevron-down': isOpen, 'fa-chevron-right': !isOpen">Toggle Me</span>
</accordion-heading>
<div class='accordion-section'>
Main content here
</div>
</accordion-group>
设置为isOpen
时。关闭后,它将设置为true
,图标切换功能将起作用。
false
可以是你喜欢的任何东西。它只是一个isOpen
属性,将被创建和设置。因此,您可以使用$scope
并在is-open="iAmOpenNow"
中使用iAmOpen
:)