Travis Konecny, Philadelphia's leading scorer with 29 points (11 goals, 18 assists), had an assist in his return to the lineup after missing three games with a concussion, and the Flyers (18-11-5) ended a three-game losing streak.
Hart won on the one-year anniversary of his recall from the American Hockey League ahead of his NHL debut Dec. 18, 2018.
WATCH: [ALL Ducks vs. Flyers highlights]
"I didn't even realize it," Hart said. "It's gone by really quick, that's for sure. ... It was a must-win game. We needed to get things turned around, and we did that tonight."
Rickard Rakell scored, and John Gibson made 27 saves for Anaheim (14-16-4).
"Some tough breakdowns," Ducks forward Jakob Silfverberg said. "I think we're doing some good stuff out there. Over the course of 60 minutes, we didn't play good enough. Any time you score one goal, it's going to be tough to win."
Philadelphia was motivated by the presence of forward Oskar Lindblom, who the Flyers announced Friday has been diagnosed with Ewing's sarcoma, a form of bone cancer. There was a video tribute for the 23-year-old during the first period, and the Flyers wore Hockey Fights Cancer jerseys during warmups.