{"action":"created","issue":{"url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/742","repository_url":"https://api.github.com/repos/apache/incubator-zeppelin","labels_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/742/comments","events_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/742/events","html_url":"https://github.com/apache/incubator-zeppelin/pull/742","id":135763871,"number":742,"title":"[ZEPPELIN-695] Add AngularJS z.runParagraph()","user":{"login":"doanduyhai","id":1532977,"avatar_url":"https://avatars.githubusercontent.com/u/1532977?v=3","gravatar_id":"","url":"https://api.github.com/users/doanduyhai","html_url":"https://github.com/doanduyhai","followers_url":"https://api.github.com/users/doanduyhai/followers","following_url":"https://api.github.com/users/doanduyhai/following{/other_user}","gists_url":"https://api.github.com/users/doanduyhai/gists{/gist_id}","starred_url":"https://api.github.com/users/doanduyhai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doanduyhai/subscriptions","organizations_url":"https://api.github.com/users/doanduyhai/orgs","repos_url":"https://api.github.com/users/doanduyhai/repos","events_url":"https://api.github.com/users/doanduyhai/events{/privacy}","received_events_url":"https://api.github.com/users/doanduyhai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-23T15:16:48Z","updated_at":"2016-03-19T14:52:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/742","html_url":"https://github.com/apache/incubator-zeppelin/pull/742","diff_url":"https://github.com/apache/incubator-zeppelin/pull/742.diff","patch_url":"https://github.com/apache/incubator-zeppelin/pull/742.patch"},"body":"### What is this PR for?\r\nAdd AngularJS `z.runParagraph()` method\r\n\r\n@corneadoug \r\nOn the client-side, inside the scope of a paragraph, we cannot access to the list of all existing paragraphs for the current note. In my previous implementation, I was using the following trick:\r\n\r\n```\r\nvar paragraphDiv = angular.element('#' + paragraphId +\r\n                                '_paragraphColumn_main[ng-controller=\"ParagraphCtrl\"]');\r\n\r\nvar paragraph = paragraphDiv.scope().paragraph;\r\n```\r\n\r\nThis is **dirty** and can be broken if we change the CSS style tomorrow for paragraph.\r\n\r\nFor the current implementation, what I did is to **inject** a reference to the `note` object into the `$scope` of paragraph so that we can access the current list of paragraph **programmatically**: \r\n\r\n```javascript\r\n        $scope.$broadcast('updateParagraph', {\r\n          note: $scope.note, // pass the note object to paragraph scope\r\n          paragraph: note.paragraphs[index]});\r\n```\r\n\r\n```html\r\n  <div id=\"{{currentParagraph.id}}_paragraphColumn_main\"\r\n       ng-repeat=\"currentParagraph in note.paragraphs\"\r\n       ng-controller=\"ParagraphCtrl\"\r\n       ng-Init=\"init(currentParagraph, note)\"\r\n```\r\n\r\n_This is a sub-task of epic **[ZEPPELIN-635]**_\r\n\r\n### What type of PR is it?\r\n[Improvement### Todos\r\n* [ ] - Code Review\r\n* [ ] - Simple Test\r\n\r\n### Is there a relevant Jira issue?\r\n**[ZEPPELIN-695]**\r\n\r\n### How should this be tested?\r\n* `git fetch origin pull/742/head:AngularJSRunParagraph`\r\n* `git checkout AngularJSRunParagraph`\r\n* `mvn clean package -DskipTests`\r\n* `bin/zeppelin-daemon.sh restart`\r\n* Create a new note\r\n* In the first paragraph, put the following code\r\n\r\n```html\r\n%angular\r\n\r\n<form class=\"form-inline\">\r\n  <div class=\"form-group\">\r\n    <label for=\"paragraphId\">Paragraph Id: </label>\r\n    <input type=\"text\" class=\"form-control\" id=\"paragraphId\" placeholder=\"Paragraph Id ...\" ng-model=\"paragraph\"></input>\r\n  </div>\r\n  <button type=\"submit\" class=\"btn btn-primary\" ng-click=\"z.runParagraph(paragraph)\"> Run Paragraph</button>\r\n</form>\r\n```\r\n* Create a second paragraph with the following code:\r\n\r\n```scala\r\nprintln(\"Date \"+new java.util.Date().toString)\r\n```\r\n* Retrieve the paragraph id of the 2nd paragraph\r\n* In the first paragraph, put the paragraph id in the input text and click on the **Run Paragraph** button, it should trigger execution of the second paragraph\r\n\r\n### Screenshots (if appropriate)\r\n![angularrunparagraph](https://cloud.githubusercontent.com/assets/1532977/13898909/ee3767bc-ede0-11e5-9996-79aa3b5c465c.gif)\r\n\r\n\r\n### Questions:\r\n* Does the licenses files need update? --> **No**\r\n* Is there breaking changes for older versions? --> **No**\r\n* Does this needs documentation? --> **Yes**\r\n\r\n[ZEPPELIN-635]: https://issues.apache.org/jira/browse/ZEPPELIN-635\r\n[ZEPPELIN-695]: https://issues.apache.org/jira/browse/ZEPPELIN-695"},"comment":{"url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/comments/198716831","html_url":"https://github.com/apache/incubator-zeppelin/pull/742#issuecomment-198716831","issue_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/742","id":198716831,"user":{"login":"doanduyhai","id":1532977,"avatar_url":"https://avatars.githubusercontent.com/u/1532977?v=3","gravatar_id":"","url":"https://api.github.com/users/doanduyhai","html_url":"https://github.com/doanduyhai","followers_url":"https://api.github.com/users/doanduyhai/followers","following_url":"https://api.github.com/users/doanduyhai/following{/other_user}","gists_url":"https://api.github.com/users/doanduyhai/gists{/gist_id}","starred_url":"https://api.github.com/users/doanduyhai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doanduyhai/subscriptions","organizations_url":"https://api.github.com/users/doanduyhai/orgs","repos_url":"https://api.github.com/users/doanduyhai/repos","events_url":"https://api.github.com/users/doanduyhai/events{/privacy}","received_events_url":"https://api.github.com/users/doanduyhai/received_events","type":"User","site_admin":false},"created_at":"2016-03-19T14:52:18Z","updated_at":"2016-03-19T14:52:18Z","body":"@Leemoonsoo \r\n\r\nThis PR too is straight forward, only JS changes"}}