javascript - generic functionality to open bootstrap $modal with Object values -
javascript - generic functionality to open bootstrap $modal with Object values -
i have created controller open $modal . how create mutual method open $modal . need pass object $modal template .
below have created controller can mutual method . , need pass object info while opening $modal [without using mill ]
html:
<a class="view-all" href="#" ng-controller="moredetailcontrollerbasic" ng-click="get_form('login')">+ add together more</a>
javascript:
viewmoreapp.controller('moredetailcontrollerbasic', ['$scope', '$http', '$compile', '$modal', function($scope, $http, $compile, $modal) { $scope.data="i trying send dataaaaaaaaaaaaaaaaaaaaaa"; $scope.get_form = function(form) { debugger; $scope.form = form; templateurl = "/form/" + form + ' '; modalinstance = $modal.open({ templateurl : '/view_more', controller : 'moredetailcontroller', //backdrop : 'static' resolve: { gallerydata: function () { homecoming $scope.data; }, } }); modalinstance.result.then(function() { //get triggers when modal closed }, function() { //gets triggers when modal dismissed. }); }; }]); viewmoreapp.controller('moredetailcontroller', ['$scope', '$http', '$compile', '$modalinstance','gallerydata', function($scope, $http, $compile, $modalinstance,gallerydata) { $scope.data_list=gallerydata; $scope.greetings="welcome wiki "; $scope.closemodal = function() { debugger; $modalinstance.dismiss('cancel'); }; }]);
i solved problem creating directive , passion info in attribute.
viewmoreapp.directive("viewmore", ['$cookies', '$http', '$compile', '$timeout', '$modal', function($cookies, $http, $compile, $timeout, $modal) { homecoming { restrict : "a", scope : { myselection: "@", }, template : "<div>click more</div>", controller : function($scope, $element, $attrs, $compile) { alert('directive init()'); $element.bind('click', function() { modalinstance = $modal.open({ templateurl : '/view_more', controller : 'moredetailcontroller', //backdrop : 'static' resolve : { gallerydata : function() { homecoming $attrs.myselection; }, } }); modalinstance.result.then(function() { //get triggers when modal closed }, function() { //gets triggers when modal dismissed. }); }); }, replace : true, transclude : true, link : function(scope, element, attrs) { } }; }]);
javascript angularjs angular-ui-bootstrap
Comments
Post a Comment