logo
down
shadow

Open $modal from the service and pass variables to the controller


Open $modal from the service and pass variables to the controller

Content Index :

Open $modal from the service and pass variables to the controller
Tag : angularjs , By : dormsbee
Date : November 23 2020, 01:01 AM

it fixes the issue I implement my own wrapper for $modal. Instead of open it in controller I would like to do that in service and then inject this service into others components , You need to fix resolve part of the service:
var modalInstance = $modal.open({
    templateUrl: "modals/modal-template.html",
    controller: "modalCtrl",
    resolve: {
        text: function() {
            return text;
        }
    }
});
modalsService.show('This is a text');

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Symfony2 pass two variables from the service to the Controller $slug


Tag : forms , By : PepeM
Date : March 29 2020, 07:55 AM
around this issue You just need to return an array from the service and access the values from the controller.
UPDATE
public function createPost (Request $request)
{
    $post = new Post();
    $post->setAuthor($this->um->getloggedUser());

    $form_post = $this->formFactory->create(new PostType(), $post);
    $form_post->handleRequest($request);

    $slug_post = $post->getSlug();

    if ($form_post->isValid())
    {
        $this->em->persist($post);
        $this->em->flush();

        return array("form_post" => true, "slug_post" => $slug_post);;
    }

    return array("form_post" => $form_post, "slug_post" => $slug_post);
}
public function newPostAction(Request $request)
{
    $ret = $this->getPostManager()->createPost($request);

    $form_post = $ret["form_post"];        

    $slug_post = $ret["slug_post"];

    if (true === $form_post)
    {
        $this->get('session')->getFlashBag()->add('success', 'Your post was submitted successfully');

        return $this->redirect($this->generateUrl('blog_blog_post_show', array('slug' => $slug_post)));
    }

    return array(
        'post_slug' => $slug_post,
        'form_post' => $form_post->createView()
    );
}

Angularjs Pass form which is inside modal controller to ng-controller outside modal


Tag : javascript , By : Tornike
Date : March 29 2020, 07:55 AM
should help you out Since your controller is a child controller of SearchCtrl, any of its descendants (except for isolated scoped directives) will automatically have doAlert function inherited. In your case you are not using scope option in modal settings so the modal scope will ultimately be $rootScope which angular ui modal does. You can provide a scope option in the settings from the controller. So:
Either set scope:$scope or if you do not want to pollute current controller scope with properties set by modal controller set a childscope, i.e scope:$scope.$new().
var modalInstance = $modal.open({
    templateUrl: '/modal-search-sort.html',
    controller: 'SearchSortFormCtrl',
    size: size,
    scope: $scope, //Or $scope.$new()
    resolve: {
        items: function () {
          return $scope.items;
        }
    }
});

Pass current controller instance to modal service


Tag : javascript , By : eataix
Date : March 29 2020, 07:55 AM
this one helps. I have a CartController, which, on showCheckout, does this: , I've fixed it by modifying AngularModalService.js as follows:
var modalScope = $rootScope.$new();
var modalScope = options.controllerScope || $rootScope.$new();
        ModalService.showModal({
            templateUrl: '/Product/CartCheckout',
            controller: 'CartController',
            controllerScope : $scope

How to watch a variable in a Service from a Controller to open a modal?


Tag : javascript , By : Kilimanjaro
Date : November 22 2020, 02:42 PM
should help you out $watch also takes a function so you could have :
http://plnkr.co/edit/oJ2CTVXKCiLwL9oNw6YR?p=preview
  $scope.$watch(function(){
    return AddTickerFactory.getToggleStatus();
  }, function(current, original) {
    vs.showModal = current;
      console.log('current',current);
      console.log('original',original);
  });

How to get variables values from a view to controller method and then pass these value to a modal to store in database:c


Tag : php , By : NeedOptic
Date : March 29 2020, 07:55 AM
this will help Here's a fast overview of CI (This is NOT meant to be copied and pasted, its just to give an idea)
Session data is available every you have loaded the session class:
  class ex_controller extends CI_controller{
        public $user;
        public function __construct()
        {
            parent::__construct();
            $this->load->library('session');
            //now we can use these methods:
             $this->user = $this->session->userdata('user_id);
         }
    }
<? echo form_open('domains/add_domain);?> <!--MUST load CI's form helper to use this-->
 <input name="domain" value="domain>
 <btn type="submit" value="ds">Submit</btn>
<? echo form_close();?>
class domains extends CI_controller{
     public function __construct()
     {
         //load requirements, like example above
     }

     public function add_domain()
     {
          //I posted data to this method, it can be accessed like:
         $domain = $this->input->post('domain');  //$this->input->post('fieldname');
         //I can then update the db by loading a model (you can load it in constructor as well
         $this->load->model('example_model');
          $this->example->add_domain($domain);
      }
 }
class Example_model extends CI_Model{
     public function __construct()
    {
         parent::__construct();
         $this->load->database();
    }

    public function add_domain($domain)
    {
        $this->db->set('column_name', $domain);
        return $this->db->insert('table');
    }
}
Related Posts Related QUESTIONS :
  • When is "onEnter" exactly executed
  • Jasmine how do I set the response of a spy
  • AngularJS date input not showing initial value inside directives in Firefox
  • What is scope of a variable inside ng-repeat block in angular js
  • Angular.Foreach in $firebaseObject
  • How to create a new instance of variables in AngularJs so that their values would be independent of the original one?
  • Is there a direct way to know to which view I am going in ionic?
  • How to use variable from a Controller in a Directive link function?
  • AngularJS - set validity of wrapped directives
  • AngularJS config causes error when minified
  • Why are my Angular, absolute path, URL's not compiling properly with Closure Compiler?
  • How to write test-case for Directive with in Directive using jasmine
  • How to pass variables from an array to ng-repeat
  • Launch an android app from Ionic app
  • Email Validation with AngularJS 1.2.0
  • How to pass data from login page to OAuth 2.0 and then get it back?
  • AngularJS routing not working properly in PhoneGap
  • AngularJS: Create new scope variable name using a variable value
  • Directive scope update does not update controller scope (AngularJs)
  • Angular UI Bootstrap4 Vertical Tabs
  • How to show/hide different data on clicking different links in AngularJS?
  • can i paste text input value on-keyup in angular?
  • ui-view do not bind to controler
  • ng-keyup doesn't execute the expression
  • Unit-test a angular controller function in a directive
  • AngularJS - always show two digits after comma
  • Angular View Showing Wrong Result
  • Angular not found until after it's needed?
  • learning angular, having issues with ng-options
  • Angularjs chat with strange polling
  • jQuery Sparkline in a cell in ng-grid using CellTemplate and Directive
  • AngularJS determine filter in controller
  • ADAL tokens not revoking on logout
  • How to deploy an app using ionic framework to Amazon? (elastic beanstalk prefered)
  • Conditional injection of a service in AngularJS
  • Filtering on object properties not working
  • Angularjs: Sorting not working in ui-grid with CellTemplate data
  • How to put serial number for rows in data table according to pagination
  • Play Application Couldn't be Started
  • Video capture to not show in my gallery on phone
  • Reject from 'response' into 'responseError'
  • Angular $injector vs inject
  • how to Avoid ng-repeat in <tr> for particular <td> - Angular Js?
  • Express route handling / req.body empty on some routes
  • AngularJS - Adding controller files triggering uncaught error
  • Using the browser to navigate back in an angularjs app with ui-router?
  • ngResource query, get and save
  • ngClick evaluated against scope instead of isolateScope
  • onEnter and onExit are not called when state is left/activated in angularjs ui router
  • Shared client & server modules with angularjs and pongular
  • Getting the angular app to run when using protractor
  • Angularjs: create a link for download different types of file
  • How to mock chained promises using Jasmine?
  • NodeJS on Heroku: Push rejected, failed to compile Node.js app
  • Ionic / Angular JS calling the next page by passing a value into a funciton
  • AngularJS - Passing select list value to function returning undefined
  • Angular JS Material mdMedia seems to be not working
  • directive does not work in the ons-toolbar
  • AngularJS : Pass variables in service
  • AngularJS - FAQ inside a modal (bug?)
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com