After loading AngularJS controller via AJAX it doesn't work
How do I instantiate a controller so that its methods can work?
I am loading via AJAX a SettingsController
, but after loading it, its methods are not callable.
What do I need to do to instantiate this code?
I looked at $compile
but it doesn't work.
Standard way of using twitter bootstrap to load partial
$("#modal").modal({remote: 'partials/users/settings.html'})
Partial loading:
%div{'ng-controller' => 'SettingsController'}
= form_tag '', 'ng-submit' => 'update_settings($event)', :method => :post do |f|
In my Customizer:
$scope.update_settings = ($event) ->
alert 'hey'
Doesn't do anything.
source to share
Ok, it looks like the problem is that you want to dynamically load some HTML into the modal. I'm not sure what you are using for your modal plugin, but you will need to do something like this:
<div id="myModal" ng-include="source"></div>
Where source is a property in your $ scope:
$scope.source = 'test.html';
Then you can listen for the event $includeContentLoaded
in your directive and call your modal function:
scope.$on('$includeContentLoaded', function () {
$('#myModal').modal();
});
Hold the angular handle to the part you want to include ... then open it with a modal.
source to share