jeudi 14 septembre 2017

Can't use variable defined in controller Angular

I'm a beginner in Angular/Jade. I can't use in view my variable "user" defined in my controller to get what is inside refs.userList. I'm on it since yesterday. Here is the code of my controller / definition & view

Here is the .jade

.module-directory

  //
  // Title
  .bg-white.b-b.b-light.wrapper.clearfix
    span.h3.pull-left.m-r Annuaire
  //

  //
  // Filters
  .panel(sk-toggle-filters)
    .p-l.p-r
      .form-horizontal.form-search
        .col.w-full.p-l
          .row
            .col-sm-3.p-b-sm.p-t-sm
              label.text-xs.text-muted Rechercher par département
              sk-input-select(ng-model='vm.userList.filter.refs.departmentList', choices='refs.departmentList', ng-change='refs.search()', placeholder='Sélectionner...', allow-clear='true')
            //- .col-sm-3.p-b-sm.p-t-sm
            //-   label.text-xs.text-muted Rechercher par employé
            //-   sk-input-select(ng-model='userList.filter.userList', choices='refs.userList', ng-change='refs.search()', placeholder='Sélectionner...', allow-clear='true')

  .h2.m-b Test : 
  .h2.m-b Test user 
  //.h2 

  // table
  //
  .col-md-3(ng-repeat="user in ::refs.userList | orderBy : 'department.id'", ng-if="user.department")
    .panel.text-center.box-shadow-lg.r-3x
      .h5.p-b
      .fake-avatar-outline.rounded.flex-center.b-success.m-auto.bg-pink
        .fake-avatar.rounded.flex-center.b-success.text-xl.m-auto.bg-pink-light 
      .h3 
      .h6.text-grey  
      span.m-t.b.b-primary.r-3x.inline.m-b.ng-binding.text-primary.text-u-c.wrapper-xs.text-xs 
      .p
      i.m-t.icon-screen-smartphone.h5.text-info : +687 
      .p.p-b

------ The controller ------

angular.module 'app'

.controller "DirectoryGridCtrl", ($scope, Refs) ->

  ################################################################################
  # actions                                                                      #
  ################################################################################

  ################################################################################
  # onLoad                                                                       #
  ################################################################################

  vm.test = "toto"
  vm.user = refs.userList

  ################################################################################
  # constructor grid                                                             #
  ################################################################################

  @grid = new Grid(resource: Directory, ctrlName: 'directoryGrid')

  ################################################################################
  # return                                                                       #
  ################################################################################
  return

and now ---- The route -----

angular.module 'app'

.config ($stateProvider) ->

  $stateProvider
    .state 'app.directory.grid',
      url: ''
      templateUrl: 'app/modules/directory/grid/directory-grid.html'
      controller: "DirectoryGridCtrl as vm"

And if you have any sugestion to improve my code, do not hesitate to tell it !! Thank you Nicolas

Aucun commentaire:

Enregistrer un commentaire