Angular.JS in Community Edition possible?

1
0
-1

Hello,

i want to use the Angular.JS Features with my Bonitasoft Community Edition. (without the customPage Section :-[ )

I develop with the Studio and BonitaSoft 6.4.1 Community.

I've tried to test with the following simple example:

my example.js

  1. angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
  2. angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl', function($scope, $http) {
  3.  
  4. $scope.selected = undefined;
  5. $scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
  6. // Any function returning a promise object can be used to load values asynchronously
  7. $scope.getLocation = function(val) {
  8. return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
  9. params: {
  10. address: val,
  11. sensor: false
  12. }
  13. }).then(function(response) {
  14. return response.data.results.map(function(item) {
  15. return item.formatted_address;
  16. });
  17. });
  18. };
  19.  
  20. $scope.statesWithFlags = [{
  21. 'name': 'Alabama',
  22. 'flag': '5/5c/Flag_of_Alabama.svg/45px-Flag_of_Alabama.svg.png'
  23. }, {
  24. 'name': 'Alaska',
  25. 'flag': 'e/e6/Flag_of_Alaska.svg/43px-Flag_of_Alaska.svg.png'
  26. }, {
  27. 'name': 'Arizona',
  28. 'flag': '9/9d/Flag_of_Arizona.svg/45px-Flag_of_Arizona.svg.png'
  29. }, {
  30. 'name': 'Arkansas',
  31. 'flag': '9/9d/Flag_of_Arkansas.svg/45px-Flag_of_Arkansas.svg.png'
  32. }, {
  33. 'name': 'California',
  34. 'flag': '0/01/Flag_of_California.svg/45px-Flag_of_California.svg.png'
  35. }, {
  36. 'name': 'Colorado',
  37. 'flag': '4/46/Flag_of_Colorado.svg/45px-Flag_of_Colorado.svg.png'
  38. }, {
  39. 'name': 'Connecticut',
  40. 'flag': '9/96/Flag_of_Connecticut.svg/39px-Flag_of_Connecticut.svg.png'
  41. }, {
  42. 'name': 'Delaware',
  43. 'flag': 'c/c6/Flag_of_Delaware.svg/45px-Flag_of_Delaware.svg.png'
  44. }, {
  45. 'name': 'Florida',
  46. 'flag': 'f/f7/Flag_of_Florida.svg/45px-Flag_of_Florida.svg.png'
  47. }, {
  48. 'name': 'Georgia',
  49. 'flag': '5/54/Flag_of_Georgia_%28U.S._state%29.svg/46px-Flag_of_Georgia_%28U.S._state%29.svg.png'
  50. }, {
  51. 'name': 'Hawaii',
  52. 'flag': 'e/ef/Flag_of_Hawaii.svg/46px-Flag_of_Hawaii.svg.png'
  53. }, {
  54. 'name': 'Idaho',
  55. 'flag': 'a/a4/Flag_of_Idaho.svg/38px-Flag_of_Idaho.svg.png'
  56. }, {
  57. 'name': 'Illinois',
  58. 'flag': '0/01/Flag_of_Illinois.svg/46px-Flag_of_Illinois.svg.png'
  59. }, {
  60. 'name': 'Indiana',
  61. 'flag': 'a/ac/Flag_of_Indiana.svg/45px-Flag_of_Indiana.svg.png'
  62. }, {
  63. 'name': 'Iowa',
  64. 'flag': 'a/aa/Flag_of_Iowa.svg/44px-Flag_of_Iowa.svg.png'
  65. }, {
  66. 'name': 'Kansas',
  67. 'flag': 'd/da/Flag_of_Kansas.svg/46px-Flag_of_Kansas.svg.png'
  68. }, {
  69. 'name': 'Kentucky',
  70. 'flag': '8/8d/Flag_of_Kentucky.svg/46px-Flag_of_Kentucky.svg.png'
  71. }, {
  72. 'name': 'Louisiana',
  73. 'flag': 'e/e0/Flag_of_Louisiana.svg/46px-Flag_of_Louisiana.svg.png'
  74. }, {
  75. 'name': 'Maine',
  76. 'flag': '3/35/Flag_of_Maine.svg/45px-Flag_of_Maine.svg.png'
  77. }, {
  78. 'name': 'Maryland',
  79. 'flag': 'a/a0/Flag_of_Maryland.svg/45px-Flag_of_Maryland.svg.png'
  80. }, {
  81. 'name': 'Massachusetts',
  82. 'flag': 'f/f2/Flag_of_Massachusetts.svg/46px-Flag_of_Massachusetts.svg.png'
  83. }, {
  84. 'name': 'Michigan',
  85. 'flag': 'b/b5/Flag_of_Michigan.svg/45px-Flag_of_Michigan.svg.png'
  86. }, {
  87. 'name': 'Minnesota',
  88. 'flag': 'b/b9/Flag_of_Minnesota.svg/46px-Flag_of_Minnesota.svg.png'
  89. }, {
  90. 'name': 'Mississippi',
  91. 'flag': '4/42/Flag_of_Mississippi.svg/45px-Flag_of_Mississippi.svg.png'
  92. }, {
  93. 'name': 'Missouri',
  94. 'flag': '5/5a/Flag_of_Missouri.svg/46px-Flag_of_Missouri.svg.png'
  95. }, {
  96. 'name': 'Montana',
  97. 'flag': 'c/cb/Flag_of_Montana.svg/45px-Flag_of_Montana.svg.png'
  98. }, {
  99. 'name': 'Nebraska',
  100. 'flag': '4/4d/Flag_of_Nebraska.svg/46px-Flag_of_Nebraska.svg.png'
  101. }, {
  102. 'name': 'Nevada',
  103. 'flag': 'f/f1/Flag_of_Nevada.svg/45px-Flag_of_Nevada.svg.png'
  104. }, {
  105. 'name': 'New Hampshire',
  106. 'flag': '2/28/Flag_of_New_Hampshire.svg/45px-Flag_of_New_Hampshire.svg.png'
  107. }, {
  108. 'name': 'New Jersey',
  109. 'flag': '9/92/Flag_of_New_Jersey.svg/45px-Flag_of_New_Jersey.svg.png'
  110. }, {
  111. 'name': 'New Mexico',
  112. 'flag': 'c/c3/Flag_of_New_Mexico.svg/45px-Flag_of_New_Mexico.svg.png'
  113. }, {
  114. 'name': 'New York',
  115. 'flag': '1/1a/Flag_of_New_York.svg/46px-Flag_of_New_York.svg.png'
  116. }, {
  117. 'name': 'North Carolina',
  118. 'flag': 'b/bb/Flag_of_North_Carolina.svg/45px-Flag_of_North_Carolina.svg.png'
  119. }, {
  120. 'name': 'North Dakota',
  121. 'flag': 'e/ee/Flag_of_North_Dakota.svg/38px-Flag_of_North_Dakota.svg.png'
  122. }, {
  123. 'name': 'Ohio',
  124. 'flag': '4/4c/Flag_of_Ohio.svg/46px-Flag_of_Ohio.svg.png'
  125. }, {
  126. 'name': 'Oklahoma',
  127. 'flag': '6/6e/Flag_of_Oklahoma.svg/45px-Flag_of_Oklahoma.svg.png'
  128. }, {
  129. 'name': 'Oregon',
  130. 'flag': 'b/b9/Flag_of_Oregon.svg/46px-Flag_of_Oregon.svg.png'
  131. }, {
  132. 'name': 'Pennsylvania',
  133. 'flag': 'f/f7/Flag_of_Pennsylvania.svg/45px-Flag_of_Pennsylvania.svg.png'
  134. }, {
  135. 'name': 'Rhode Island',
  136. 'flag': 'f/f3/Flag_of_Rhode_Island.svg/32px-Flag_of_Rhode_Island.svg.png'
  137. }, {
  138. 'name': 'South Carolina',
  139. 'flag': '6/69/Flag_of_South_Carolina.svg/45px-Flag_of_South_Carolina.svg.png'
  140. }, {
  141. 'name': 'South Dakota',
  142. 'flag': '1/1a/Flag_of_South_Dakota.svg/46px-Flag_of_South_Dakota.svg.png'
  143. }, {
  144. 'name': 'Tennessee',
  145. 'flag': '9/9e/Flag_of_Tennessee.svg/46px-Flag_of_Tennessee.svg.png'
  146. }, {
  147. 'name': 'Texas',
  148. 'flag': 'f/f7/Flag_of_Texas.svg/45px-Flag_of_Texas.svg.png'
  149. }, {
  150. 'name': 'Utah',
  151. 'flag': 'f/f6/Flag_of_Utah.svg/45px-Flag_of_Utah.svg.png'
  152. }, {
  153. 'name': 'Vermont',
  154. 'flag': '4/49/Flag_of_Vermont.svg/46px-Flag_of_Vermont.svg.png'
  155. }, {
  156. 'name': 'Virginia',
  157. 'flag': '4/47/Flag_of_Virginia.svg/44px-Flag_of_Virginia.svg.png'
  158. }, {
  159. 'name': 'Washington',
  160. 'flag': '5/54/Flag_of_Washington.svg/46px-Flag_of_Washington.svg.png'
  161. }, {
  162. 'name': 'West Virginia',
  163. 'flag': '2/22/Flag_of_West_Virginia.svg/46px-Flag_of_West_Virginia.svg.png'
  164. }, {
  165. 'name': 'Wisconsin',
  166. 'flag': '2/22/Flag_of_Wisconsin.svg/45px-Flag_of_Wisconsin.svg.png'
  167. }, {
  168. 'name': 'Wyoming',
  169. 'flag': 'b/bc/Flag_of_Wyoming.svg/43px-Flag_of_Wyoming.svg.png'
  170. }];
  171. });

in the head from the file C:\BonitaBPMCommunity-6.4.1\workspace\tomcat\bonita\client\tenants\1\work\theme\portal\BonitaForm.html i've added this:

  1. <!doctype html>
  2. <html ng-app="ui.bootstrap.demo">
  3. <head>
  4. <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
  5. <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.1.js"></script>
  6. <script src="example.js"></script>
  7. <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
  8. </head>

In the FormDesigner i added a HTML-Widget which i filled with the following:

  1. <script type="text/ng-template" id="customTemplate.html">
  2. <a>
  3. <img ng-src="http://upload.wikimedia.org/wikipedia/commons/thumb/{{match.model.flag}}" width="16">
  4. <span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
  5. </a>
  6. <div class='container-fluid' ng-controller="TypeaheadCtrl">
  7.  
  8. <h4>Static arrays</h4>
  9. <pre>Model: {{selected | json}}</pre>
  10. <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control">
  11.  
  12. <h4>Asynchronous results</h4>
  13. <pre>Model: {{asyncSelected | json}}</pre>
  14. <input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http" typeahead="address for address in getLocation($viewValue)" typeahead-loading="loadingLocations" class="form-control">
  15. <i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
  16.  
  17. <h4>Custom templates for results</h4>
  18. <pre>Model: {{customSelected | json}}</pre>
  19. <input type="text" ng-model="customSelected" placeholder="Custom template" typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-template-url="customTemplate.html" class="form-control">
  20. </div>

You can check the sample at http://plnkr.co/edit/?p=preview My Output looks like the working WebExample but it doesnt load the values.

I get no Errors!

Can someone help me.

Thx

Comments

Submitted by jathagrimon on Thu, 02/26/2015 - 21:59

a little step forward in error-details:

the problem is that bonitaSoft loads the content dynamic and angular doesnt know the code. When i define the div directly in the BonitaForm.html can angular work without problems.

When you look at the sourceCode you can find the div.

But my Div is in the FormularDesigner attached as an HTML-Widget.

When you search in the sourceCode you can not find this div. It was dynamicallly loaded with javascript!!!

I think thats the problem. How to resolve?

No answers yet.
Notifications