Skip to content
Snippets Groups Projects
Commit 9720649e authored by totten's avatar totten
Browse files

"AngularJS: Quick Start" -- Various tweaks

parent 63465e08
No related branches found
No related tags found
No related merge requests found
...@@ -37,42 +37,40 @@ Write ang/aboutme.css ...@@ -37,42 +37,40 @@ Write ang/aboutme.css
is not required -- the option `--am` can specify a different name. This is not required -- the option `--am` can specify a different name. This
can be useful if you want to organize your code into multiple modules. can be useful if you want to organize your code into multiple modules.
!!! note "Note: `ang/` folder"
By convention, AngularJS source code is stored in the `ang/` folder, and
each item is named after its module. The convention is discussed in
more detail in [AngularJS: File Names](/framework/angular/files.md)
The first file, `ang/aboutme.ang.php`, configures the file-loader: The first file, `ang/aboutme.ang.php`, provides metadata for the PHP-based
file-loader, e.g.
```php ```php
return array( return array(
'requires' => array('crmUi', 'crmUtil', 'ngRoute'), 'requires' => array('ngRoute', 'crmUi', 'crmUtil'),
'js' => array( 'js' => array('ang/aboutme.js', 'ang/aboutme/*.js', 'ang/aboutme/*/*.js'),
'ang/aboutme.js', 'css' => array('ang/aboutme.css'),
'ang/aboutme/*.js',
'ang/aboutme/*/*.js',
),
'css' => array ('ang/aboutme.css'),
'partials' => array('ang/aboutme'), 'partials' => array('ang/aboutme'),
'settings' => array(), 'settings' => array(),
); );
``` ```
And the second file, `ang/aboutme.js`, declares the Angular module's dependencies. The second file, `ang/aboutme.js`, provides metadata for the JS-based
Angular runtime, e.g.
```js ```js
angular.module('aboutme', [ angular.module('aboutme', [
'crmUi', 'crmUtil', 'ngRoute' 'ngRoute', 'crmUi', 'crmUtil'
]); ]);
``` ```
!!! tip "Tip: angular.module() and angular.crmDepends()" !!! tip "Tip: angular.module() and CRM.angRequires()"
The list of dependencies is declared once in PHP and once in JS. To The list of dependencies is declared once in PHP and once in JS. To
remove this duplication, change `angular.module('aboutme',...)` to remove this duplication, replace the array `['ngRoute', 'crmUi', 'crmUtil']`
`angular.crmDepends('aboutme');` with a function call `CRM.angRequires('aboutme')`.
!!! note "Note: `ang/` folder"
By convention, AngularJS source code is stored in the `ang/` folder.
The convention is discussed in more detail in [AngularJS: File
Names](/framework/angular/files.md)
## Add an Angular route, etal ## Add an Angular-based page
Now let's add a new Angular-based page. This page will require a `route` Now let's add a new Angular-based page. This page will require a `route`
with a `controller` and an HTML template. The command `civix with a `controller` and an HTML template. The command `civix
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment