Despite these differences, slope and elasticity are not entirely unrelated concepts, and it is possible to figure out how they relate to each other mathematically. We can do this by starting with the formula for price elasticity of demand. A percent change is just an absolute change (i.e. final minus initial) divided by the initial value, so a percent change in quantity demanded is just the absolute change in quantity demanded divided by quantity demanded, and a percent change in price is just the absolute change in price divided by price. Some simple arithmetic then tells us that price elasticity of demand is equal to the absolute change in quantity demanded divided by the absolute change in price, all times the ratio of price to quantity. The first term in that expression is just the reciprocal of the slope of the demand curve, so the price elasticity of demand is equal to the reciprocal of the slope of the demand curve times the ratio of price to quantity. (Technically, if price elasticity of demand is represented by an absolute value, then it is equal to the absolute value of the quantity defined here.)
This comparison highlights the fact that it's important to specify the range of prices over which elasticity is calculated, since elasticity is not constant even when the slope of the demand curve is constant, as is the case with demand curves that are represented by straight lines. It is possible, however, for a demand curve to have constant price elasticity of demand, but these types of demand curves will not be straight lines and will thus not have constant slopes.