Joey Gallo, Anderson Tejada, Sam Huff, Rougned Odor and Derek Dietrich homered for the Rangers.
The Angels are several games out of a playoff spot going into the final week while the Rangers have been eliminated.
Cody (1-1) allowed just three hits and one run in a career-high five innings, striking out five without a walk. He retired 11 straight before Chris Woodward went to the bullpen.
Cody knew he had a five-inning limit, and he punctuated his strikeout of Andrelton Simmons to end the fifth with a fist pump.
''I'm not a huge fan of showing emotions and all the antics, but it's been a long time since I've gone five innings,'' Cody said. ''It's been two, three years since I've gone that long and to be able to go and continue to execute pitches and give my team a chance to win, that felt really good in that moment.''
The 26-year-old rookie exited with a 1.53 ERA in seven big league games, including four starts.
Cody gave up a double to Justin Upton in the second and Taylor Ward had an RBI single to get the Angels within 3-1, but otherwise he kept the Angels off-balance.
Julio Teheran (0-4) was chased in the second inning for the second consecutive game.
Gallo hit a two-run homer off Teheran in the first and Tejada had a leadoff drive in the second. Teheran has given up 12 home runs in 30 1/3 innings this season.
Huff, the 22-year-old catching prospect who made his big league debut earlier this month, hit his first career home run, a shot in the fourth to left-center field off a rock in the water fountain.
It was a banner day for the batterymates who were both drafted in 2016. And it took Huff a while to even realize he'd hit a 410-foot home run.
''I looked up and recognized I did it,'' Huff said. ''It got on me quick. It was fun. I was rounding second base and it didn't really hit me before that.''
He said he'll give his first home run ball to his father.
Patrick Sandoval pitched 4 1/3 innings of solid relief for the Angels, with his only blemish the homer to Huff. He kept the Angels close but Odor and Dietrich homered off reliever Ty Buttrey in the eighth.
With the Angels in a must-win situation to have a shot at the postseason, Maddon pulled Teheran after he allowed three runs on two home runs and faced just seven betters.
''Everything's a little bit off. There's no deception in the zone right now for him, which he'll eventually get back,'' Maddon said. ''But for right now under the shortened conditions, the fact that, like I said, had a late start, all these things are contributing factors. But I talked to him about it. I let him know it was something I had to do. He understood. He understood it was about the team first. But it wasn't going to get any better and that's why I did what I did.''
Rangers: INF Ronald Guzman left the game with tightness in his right hamstring after he tried to run out a grounder to first.
Angels: INF Franklin Barreto will have shoulder surgery this week, according to Maddon ... OF Upton, who was hit in the helmet on Friday and left the game, was back in Sunday's lineup.
Rangers: RHP Kyle Gibson (2-5, 5.18) is coming off one of the best starts of his career, throwing a complete game shutout in Texas' 1-0 win over Houston. He struck out nine and allowed just four hits in the win.
Angels: RHP Dylan Bundy (5-3, 3.12) is 4-1 with a 2.61 ERA in eight career appearances against the Rangers. He ranks sixth among American League pitchers with a 1.01 WHIP.
The Rangers acquired minor league RHP Stephen Villines from the Mets to complete the Aug. 5 trade that sent RHP Ariel Jurado to New York.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Copyright 2021 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.