Wednesday, November 30, 2016

ng-repeat category by field


http://stackoverflow.com/questions/17514272/filtering-an-ng-repeat-list-based-on-a-sub-object-property

you are allowed to create new scope members inside the expressions.

filterdGoals1 and filterdGoals2 executed before it is being used

<div class="cfaesProfile_box">
  <div ng-repeat="goal in filterdGoals1 = (source.goals | filter: {goal_type:'1'} | filter:{goal_year:year.value})"></div>
  <div ng-repeat="goal in filterdGoals2 = (source.goals | filter: {goal_type:'2'} | filter:{goal_year:year.value})"></div>
  len={{filterdGoals.length}}
  <div ng-show="filterdGoals1.length">Performance</div>
  <div ng-if="year.value == goal.goal_year && !year.collapsed"          ng-repeat="goal in filterdGoals1">
    <div class="publist box-pop">
      <div class="cfaesProfile_row">
        <div ng-click="editGoal($index)"             class="cfaesProfile_option cfaesProfile_control fa fa-pencil"></div>
        <div class="cfaesProfile_option cfaesProfile_control fa fa-files-o"></div>
        <div class="cfaesProfile_option cfaesProfile_control fa fa-trash-o"></div>
        <div ng-click="goal.locked = !goal.locked"             ng-class="goal.locked ? 'fa-unlock' : 'fa-lock'"             class="cfaesProfile_option cfaesProfile_control fa"></div>
        <div class="cfaesProfile_label">
          <div ng-class-odd="depth_1" ng-class-odd="depth_1_alt">
            <span class="label_element goal-title">{{goal.goal_no}}.&nbsp{{goal.goal_content}}</span></br>
            <span class="label_element goal-title">{{goal.goal_progress}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div ng-show="filterdGoals2.length">Professonal Development</div>
  <div ng-if="year.value == goal.goal_year && !year.collapsed"       ng-repeat="goal in filterdGoals2">
    <div class="publist box-pop">
      <div class="cfaesProfile_row">
        <div ng-click="editGoal($index)"             class="cfaesProfile_option cfaesProfile_control fa fa-pencil"></div>
        <div class="cfaesProfile_option cfaesProfile_control fa fa-files-o"></div>
        <div class="cfaesProfile_option cfaesProfile_control fa fa-trash-o"></div>
        <div ng-click="goal.locked = !goal.locked"             ng-class="goal.locked ? 'fa-unlock' : 'fa-lock'"             class="cfaesProfile_option cfaesProfile_control fa"></div>
        <div class="cfaesProfile_label">
          <div ng-class-odd="depth_1" ng-class-odd="depth_1_alt">
            <span class="label_element goal-title">{{goal.goal_no}}.&nbsp{{goal.goal_content}}</span></br>
            <span class="label_element goal-title">{{goal.goal_progress}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Tuesday, November 22, 2016

webStorm To surround a block of code, add block of code



Surrounding blocks of code


To surround a block of code

  1. Select the desired code fragment.
  2. Do one of the following:
    • On the main menu, choose Code | Surround With
    • Press Ctrl+Alt+T.
    A pop-up window displays the list of enclosing statements according to the context.
  3. Select the desired surround statement from the list. To do that, use the mouse cursor, up and down arrow keys, or a shortcut key displayed next to each element of the list.

Thursday, November 17, 2016

Monday, November 14, 2016

array sort


$scope.partnership.sort(function compare(a, b) {
      if (parseInt(a.displayOrder) < parseInt(b.displayOrder))
          return -1;
      if (parseInt(a.displayOrder) > parseInt(b.displayOrder))
          return 1;
      return 0;
  }
);

Saturday, November 12, 2016

print screen on Surface 3


The Surface Pro 3 Type covers lacks the traditional PrintScreen button which is useful for grabbing a quick screenshot of yourscreen. A workaround is to simply press Fn + Windows + Space in sequence. The screenwill dim briefly and then a screenshot will be stored in Pictures\Screenshots.Aug 6, 2014

Thursday, November 10, 2016

dynamically change orderBy in ng-repeat



<tr ng-repeat="ar in arrSOA  | orderBy: orderByVar">

just use logic in js file to change $scope.orderByVar

$scope.addSOA = function () {
    $scope.displayOrderChanged = false;
   $scope.showAddSOA = true;
    $scope.orderByVar = "$index";
....

Wednesday, November 9, 2016

custom filter $scope not defined


http://stackoverflow.com/questions/17596246/access-scope-variables-from-a-filter-in-angularjs

app.controller('AppController',
    function($scope) {
      $scope.var1 = 'This is some text.';
      $scope.var2 = 'And this is appended with custom filter.';
    }
  );


app.filter('filterReceiptsForDate', function () {
  return function (input, scope) {
    return input + ' <strong>' + scope.var2 + '</strong>';
  };
});

ng-repeat orderBy

| orderBy:'displayOrder'

gui call microservice

http request (GUI) to micro service (node js )

             _request.getJSON("/cfaes", request, bodyObj, function (rqstId, data, err) {


Service.prototype.UpdateScopeOfAudienceBulk = function(req, res, next) {

when done everything, need to return to GUI
put results in req.result

req.result = {};
req.result.count = count;
next(); // this will return back to GUI from micro service

confusing part is "next" is kind of corresponding to err

Tuesday, November 8, 2016

Convert array to JSON

http://stackoverflow.com/questions/2295496/convert-array-to-json

http://stackoverflow.com/questions/191881/serializing-to-json-in-jquery

var myJsonString = JSON.stringify(yourArray);
var jsonArray = JSON.parse(JSON.stringify(pluginArrayArg))

Monday, November 7, 2016

moongoose bulk update


http://codingmiles.com/nodejs-bulk-update-to-mongodb-using-mongoose/

http://blog.mongodb.org/post/84922794768/mongodbs-new-bulk-api

Wednesday, November 2, 2016

move array element



http://stackoverflow.com/questions/5306680/move-an-array-element-from-one-array-position-to-another