Limiting the rotation of an object

I'm using a Object (Cannon) that rotates only in 2 axis. And I'm trying to limit the rotation that this Cannon can do.

My object start with all Rotation in 0. And I want the rotation is limited from 0 to -90 (270).

=> This object cant rotate to angles > (more than) 0, and < (less than) 270 (or -90)

I mean: (angle < 0 && angle > 270)

A little CODE:

    transform.rotation = Quaternion.LookRotation(inputRotation); // inputRotation get the mouse position (x, z). Z get the value of Y.      
    transform.eulerAngles = new Vector3(0, 0, -transform.eulerAngles.y + 0);//-transform.eulerAngles.y + 0);

And I found this code to limit the rotation, but when I put the mouse in a position that give a angle more than 0, the object back to the value -90. If the object stayed in the position 0 when angle were more than 0, and stayed in -90 (or 270) when the angle were less than 270 will fixed.

The function to limit:

function LateUpdate()
{
     transform.rotation.eulerAngles = new Vector3(
          transform.rotation.eulerAngles.x,
          transform.rotation.eulerAngles.y,
          Mathf.Clamp(transform.rotation.eulerAngles.z, 270, 360)
     );
}

Thks for all!

I had a similar problem (see here) that was solved by using transform.localEulerAngles instead.