New to angular here. I'm creating a top-nav directive, like so:
<html>
<body ng-app="myApp">
<top-nav></top-nav>
</body>
</html>
This works fine. However, let's say I have a button outside of the top-nav that needs to call the showLoginDialog() method within the topNav's controller.
In order for this to work, I will need to isolate the controller from the top-nav like so:
<html>
<body ng-app="myApp">
<div ng-controller="TopNavController as topNav">
<top-nav></top-nav>
</div>
<!-- assume more markup here.... -->
<button ng-click="topNav.showLoginDialog()">
</body>
</html>
My question is: Is this considered bad practice? That is, removing the controller from the directive so that something outside can access it?
Edit: FYI - my "login popup" appears when you click the "Login" button in my top-nav. However, I also want this "login popup" to be able to popup when one clicks on the giant "Register" button in my home page. This is why I've asked how to call it from outside.