How is angular momentum conserved for the orbiting body if the centripetal force disappears?

If the Sun were to magically disappear then the Earth would fly off at a tangent to its orbit. The trajectory would look like this:

Earth trajectory

The green dot shows the position of the Earth at the instant the Sun disappears. The distance from the Sun, $d$, is the Earth's orbital distance and the velocity $v$ is the Earth's orbital velocity.

When the Sun disappears the Earth heads off in a straight line at constant velocity as shown by the horizontal dashed line, so after some time $t$ it has moved a distance $x = vt$ as I've marked on the diagram. The question is now how the angular momentum can be conserved.

The answer is that angular momentum is given by the vector equation:

$$ \mathbf L = \mathbf r \times m\mathbf v $$

where $\mathbf r$ is the position vector, $\mathbf v$ is the velocity vector and $\times$ is the cross product. We are going to end up with the vector $\mathbf L$ pointing out of the page and the magnitude of $L$ is given by:

$$ |\mathbf L| = m\,|\mathbf r|\,|\mathbf v|\,\sin\theta \tag{1} $$

but looking at our diagram we see that:

$$ \sin\theta = \frac{d}{|\mathbf r|} $$

and if we substitute this into our equation (1) for the angular momentum we get:

$$ |\mathbf L| = m\,|\mathbf r|\,|\mathbf v|\,\frac{d}{|\mathbf r|} = m\,|\mathbf v|\,d \tag{2} $$

And this equation tells us that the angular momentum is constant i.e. it depends only on the constant velocity $\mathbf v$ and the original orbital distance $d$.

Although it initially seems odd an object doesn't have to be moving in a circle to have a constant angular momentum. In fact for any system the angular momentum is always constant unless some external torque is acting on the system.

Go back to 0:46 in the video to see how angular momentum is calculated. $$L = mrv_{rot}$$ where $L$ is the angular momentum, $m$ is the mass of the object, $r$ is the distance of the object from the center of rotation, and $v_{rot}$ is the velocity of motion along the circle centered at the center of rotation with a radius equal to $r$. Usually, angular momentum is most usefully employed when objects are undergoing circular motion because the calculation is easiest--$m$, $r$, and $v_{rot}$ are all constant, which means $L$ is constant.

However, it is not only circular motion that can usefully use angular momentum. A planet orbits a star in an elliptical orbit, and yet the angular momentum is constant. Since the mass of a planet largely doesn't change, we can conclude that the speed of the planet ($v_{rot}$) is large when it is close to the star ($r$ is small) and vice versa. In this system, the center of rotation is the star which is not the geometric center of the orbit (the center of the ellipse).

We can go further and say that the angular momentum can be calculated with respect to any point in space--that is, the point we call the "center of rotation" is just a label that can be put anywhere. There doesn't have to be anything significant at the center of rotation. True, for most problems, putting the center of rotation at the center of circular motion is the correct thing to do for calculation purposes since that will make the calculated angular momentum constant. [1] In the video at 1:56, after the sun disappears, the angular momentum of the Earth is calculated with respect to the same point: where the sun used to be. So, $m$, $r$, and $v_{rot}$ are all still the same, and therefore $L$ is the same. As the Earth moves off in a straight line, the distance to the point ($r$) increases while the velocity in the direction of what would be circular motion ($v_{rot}$) decreases. This decrease occurs because the motion required for circular motion is in a different direction than the planet's actual motion, so less and less of Earth's velocity counts towards $v_{rot}$. [2] The changes in $r$ and $v_{rot}$ cancel each other out, leaving a constant angular momentum.

[1] Somewhat more technical aside: angular momentum is constant if the direction of the sum total force on an object is parallel to a line joining the object and the designated center of rotation. Note that the gravitational force between a planet and the star it orbits satisfies this constraint. So does an object with zero total force on it, since the zero vector is parallel to every vector.

[2] For a simpler example of this: if I am driving in my car in a north-eastern direction, only part of my car's speed is carrying me north. If I steer to the right to go in a more easterly direction while keeping the same speed, then less of my velocity will be in the northern direction, so I won't make as much progress towards the north compared to my earlier direction.

Angular momentum is measured relative to some origin. So the angular momentum of a system is different for different reference frames. However for a closed system in a given reference frame the total angular momentum of the system is constant over time.

If we set our origin at the center of rotation, the angular momentum of the orbiting body is $$L=mr_0v$$ where $r_0$ is the distance between the body and the center of rotation.

After the force disappears, the body continues to move along a straight line tangetially to its former orbit. It's trajectory can be given by $$\vec{r}(t)=\begin{pmatrix} -vt \\ r_0 \end{pmatrix} $$ and the angular momentum is $$L=m \;\vec{r}\times \vec{v}=m\begin{pmatrix} -vt \\ r_0 \end{pmatrix}\times \begin{pmatrix} -v \\ 0 \end{pmatrix}=mr_0v$$ As you can see, angular momentum is conserved.

However by doing this we are treating the centripetal force on the body as an external force (we are neglecting the reaction force from newtons third law on another object). Since angular momentum is only conserved for closed systems, angular momentum is not conserved in general in this approximation. This approximation only works because we have chosen our origin such that the position vector $\vec{r}$ is always parallel to the force $\vec{F}$ on the body and therefore the force doesn't produce torque $\vec{r}\times\vec{F}$, such that angular momentum is again conserved. If we would choose any other origin, it wouldn't work.

If we don't make such an assumption and calculate the angular momentum of two objects which orbit each other in a closed system (such as earth and the sun), we can choose any origin we want and angular momentum is always conserved.