Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9ee2cdf

Browse files
committed
refactor(directives): connect new compiler
- turn everything into a directive
1 parent 8af4fde commit 9ee2cdf

36 files changed

+1558
-1734
lines changed

css/angular.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@charset "UTF-8";
22

3-
[ng\:cloak], .ng-cloak {
3+
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
4+
.ng-cloak, .x-ng-cloak {
45
display: none;
56
}
67

docs/content/api/angular.inputType.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ All `inputType` widgets support:
8484
it('should invalidate on wrong input', function() {
8585
expect(element('form[name=myForm]').prop('className')).toMatch('ng-valid');
8686
input('data').enter('{}');
87-
expect(binding('data')).toEqual('data={\n }');
87+
expect(binding('data')).toEqual('{}');
8888
input('data').enter('{');
8989
expect(element('form[name=myForm]').prop('className')).toMatch('ng-invalid');
9090
});

docs/content/guide/dev_guide.expressions.ngdoc

+10-6
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,20 @@ Extensions: You can further extend the expression vocabulary by adding new metho
185185
{name:'Julie', phone:'555-8765'}]"></div>
186186
Search: <input ng:model="searchText"/>
187187
<table class="example3">
188-
<tr><th>Name</th><th>Phone</th><tr>
189-
<tr ng:repeat="friend in friends | filter:searchText">
190-
<td>{{friend.name}}</td>
191-
<td>{{friend.phone}}</td>
192-
</tr>
188+
<thead>
189+
<tr><th>Name</th><th>Phone</th><tr>
190+
</thead>
191+
<tbody>
192+
<tr ng:repeat="friend in friends | filter:searchText">
193+
<td>{{friend.name}}</td>
194+
<td>{{friend.phone}}</td>
195+
</tr>
196+
</tbody>
193197
</table>
194198
</doc:source>
195199
<doc:scenario>
196200
it('should filter the list', function() {
197-
var tr = using('table.example3').repeater('tr.ng-attr-widget');
201+
var tr = using('table.example3 tbody').repeater('tr');
198202
expect(tr.count()).toBe(5);
199203
input('searchText').enter('a');
200204
expect(tr.count()).toBe(2);

docs/content/guide/dev_guide.forms.ngdoc

+25-24
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,20 @@ The following example demonstrates:
277277

278278
This example shows how to implement a custom HTML editor widget in Angular.
279279

280-
<doc:example>
280+
<doc:example module="formModule">
281281
<doc:source>
282282
<script>
283283
function EditorCntl($scope) {
284284
$scope.htmlContent = '<b>Hello</b> <i>World</i>!';
285285
}
286286

287-
HTMLEditorWidget.$inject = ['$element', '$scope', 'htmlFilter'];
288-
function HTMLEditorWidget(element, scope, htmlFilter) {
287+
HTMLEditorWidget.$inject = ['$scope', '$element', '$sanitize'];
288+
function HTMLEditorWidget(scope, element, $sanitize) {
289289
scope.$parseModel = function() {
290290
// need to protect for script injection
291291
try {
292-
this.$viewValue = htmlFilter(
293-
this.$modelValue || '').get();
292+
this.$viewValue = $sanitize(
293+
this.$modelValue || '');
294294
if (this.$error.HTML) {
295295
// we were invalid, but now we are OK.
296296
this.$emit('$valid', 'HTML');
@@ -312,32 +312,33 @@ This example shows how to implement a custom HTML editor widget in Angular.
312312
});
313313
}
314314

315-
angular.directive('ng:html-editor-model', function() {
316-
return ['$formFactory', '$element', function ($formFactory, element) {
317-
var exp = element.attr('ng:html-editor-model'),
318-
form = $formFactory.forElement(element),
319-
widget;
320-
element.attr('contentEditable', true);
321-
widget = form.$createWidget({
322-
scope: this,
323-
model: exp,
324-
controller: HTMLEditorWidget,
325-
controllerArgs: {$element: element}});
326-
// if the element is destroyed, then we need to
327-
// notify the form.
328-
element.bind('$destroy', function() {
329-
widget.$destroy();
330-
});
331-
}];
332-
});
315+
angular.module.formModule = function($compileProvider){
316+
$compileProvider.directive('ngHtmlEditorModel', function ($formFactory) {
317+
return function(scope, element, attr) {
318+
var form = $formFactory.forElement(element),
319+
widget;
320+
element.attr('contentEditable', true);
321+
widget = form.$createWidget({
322+
scope: scope,
323+
model: attr.ngHtmlEditorModel,
324+
controller: HTMLEditorWidget,
325+
controllerArgs: {$element: element}});
326+
// if the element is destroyed, then we need to
327+
// notify the form.
328+
element.bind('$destroy', function() {
329+
widget.$destroy();
330+
});
331+
};
332+
});
333+
};
333334
</script>
334335
<form name='editorForm' ng:controller="EditorCntl">
335336
<div ng:html-editor-model="htmlContent"></div>
336337
<hr/>
337338
HTML: <br/>
338339
<textarea ng:model="htmlContent" cols="80"></textarea>
339340
<hr/>
340-
<pre>editorForm = {{editorForm}}</pre>
341+
<pre>editorForm = {{editorForm|json}}</pre>
341342
</form>
342343
</doc:source>
343344
<doc:scenario>

0 commit comments

Comments
 (0)