我使用angularjs。查看项目的子项目及其子项目等。 当我点击例如等级1-1,我想知道有多少个子牌被打开了。怎么做?
这是html代码:
主要级别
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="divMain">
<div id="divGeneralDetails">divGeneralDetails</div>
<div id="divLanguageDetails">divLanguageDetails</div>
<div id="divLinkDetails">divLinkDetails</div>
<div id="divOperationalDetails">divOperationalDetails</div>
</div>
<button onclick="moveOperationalToTop()">Move Operational to top</button>
电平child.tmpl.html
func serverRequestAuth(_ requestName: String, control:@escaping (_ check : Bool)-> Void){
let requestNameEscaped = requestName.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
var request = NSMutableURLRequest()
request = NSMutableURLRequest(url: URL(string: "\(self.view.getServerPath())\(requestNameEscaped)")!, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 5)
request.httpMethod = "GET"
request.setValue(self.view.getAuth(), forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request as URLRequest) {data, response, err in
if data != nil {
if let dictionary = self.parseJSONData(data!) {
self.parseDictionary(dictionary, typeOfRequest: requestName)
control(true)
}else{
control(false)
}
}
}
task.resume()
}
解决了问题
我有下一级DOM元素。所以我只检查它是否存在,如果它是真的 - 我只是发送它的孩子来检查是否存在。如果是 - 等级++
serverRequestAuth("myStringRequest1", control: {(check)in
if check {
self.serverRequestAuth("myStringRequest2", control: {(check) in
if check {
self.tableView.reloadData()
}else{
print("error Request 2")
}
})
}else {
print("error request 1")
}
})
答案 0 :(得分:0)
Solved。使用Solved *
更新了我的问题