I have a register page that uses text inputs as well as an avatar input. There's another part in the website where the avatar input is also used, but it's used alone this time. So I'd like to make it reusable and since it's coupled to a part of a view, I want to use a controller for this.
Simplified, here's how it looks like :
<body ng-controller="RegisterController as RegisterCtrl"> <form ng-submit="RegisterCtrl.submit(AvatarCtrl)"> <div class="avatar" ng-controller="AvatarController as AvatarCtrl"> <input type="file" ng-model="AvatarCtrl.avatar" /> </div> <input type="text" ng-model="RegisterCtrl.credentials.name" /> <input type="submit" value="Submit" /> </form> </body>
I thought about using events, but I thought I needed the AvatarController data to work with, and that was the most simple way to do it.