angular ui bootstrap - Submit form in AngularJs Modal -


i'm trying submit simple form input in modal (popup) written in angularjs:

myapp.run(function($rootscope, $modal) {      $rootscope.$on('$statechangestart', function(event, tostate) {          if (tostate.name == 'statepopup') {              $modal.open({                 templateurl : 'popup.html',                 controller : 'allegaticontroller',                 backdrop: 'static'             });              event.preventdefault();          } else {              return;         }     }) }) 

the form html :

<form>     <div class="form-group">         <label>file name:</label>          <input type="text"  ng-model="name"></input>     </div>     <button ng-click="save()" class="btn btn-primary">save</button>  </form> 

in controller.js : $scope.name came undefined

updated:

this controller:

function mycontroller($scope) {     console.log("all mycontroller");        $scope.save = function() {          var name= $scope.name;         console.log('name '+name);       } } 

maybe seems in run of model defined app missed $scope parameter ?

what missed in code?

if have this:

$modal.open({     templateurl : 'popup.html',     controller : 'allegaticontroller',     backdrop: 'static' }); 

your controller should be:

myapp.controller('allegaticontroller', ['$scope', function ($scope) {     console.log('all mycontroller');      $scope.save = function () {        var name = $scope.name;        console.log('name '+name);     } }]); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -