Cook the pasta according to package instructions in a large pot of salted boiling water until al dente. Reserve 1/2 cup of pasta water, then drain the pasta and set aside.
In a large skillet, heat the olive oil over medium heat. Add the sliced onions and salt, stirring to coat the onions in the oil. Cook for about 15-20 minutes, stirring occasionally, until the onions are caramelized and golden brown.
Sprinkle the sugar over the onions and continue to cook for an additional 5 minutes, stirring frequently. This will enhance the sweetness of the onions.
Add the minced garlic and red pepper flakes to the skillet, cooking for another 1-2 minutes until fragrant.
Toss the cooked pasta into the skillet with the caramelized onions. Add reserved pasta water a little at a time until the desired consistency is reached. Mix well to combine.
Stir in the grated Parmesan cheese and season with salt and pepper to taste. Remove from heat.
Serve the pasta warm, garnished with fresh parsley and an extra sprinkle of Parmesan if desired.