Answers for "set angular fire to model with id"

0

Angular - dynamically set model property of object bound to radio button based on its state

function setTrueFalseRadioState(answer) {
     angular.forEach(vm.files, function (a) {
        if (a.IsMyChoice !== answer.IsMyChoice) {
            a.IsMyChoice = false;
        }
     });
 };

 vm.setTrueFalseRadioState = setTrueFalseRadioState;


I discovered that if you want to send the object data to the backend server, you need to set the ng-value to its index
  
  <input type="radio"
         id="isChoice_{{$index + 1}}"
         name="response"
         ng-value="{{$index + 1}}"
         ng-required="!file.IsMyChoice"
         ng-change="get.setTrueFalseRadioState(file)"
         data-ng-model="file.IsMyChoice" />

and the use javascript to check the values like:

  if (file.IsMyChoice !== undefined) {
     file.IsMyChoice !== false ?
     file.IsMyChoice = 'true' : file.IsMyChoice = 'false';
  }
Posted by: Guest on May-26-2020
0

how to get phone setting url in swfit 4

override func viewDidAppear(_ animated: Bool) {
    let alertController = UIAlertController (title: "Title", message: "Go to Settings?", preferredStyle: .alert)

    let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -> Void in

        guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
            return
        }

        if UIApplication.shared.canOpenURL(settingsUrl) {
            UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                print("Settings opened: (success)") // Prints true
            })
        }
    }
    alertController.addAction(settingsAction)
    let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil)
    alertController.addAction(cancelAction)

    present(alertController, animated: true, completion: nil)
}
Posted by: Guest on November-26-2019

Code answers related to "Swift"

Browse Popular Code Answers by Language