I'd prefer a solution that didn't have arrays passed around and searched in the directive. However, this is definitely the most straight forward solution and other ways might take a bit longer to iron out.