How to use angular - 10 common examples

To help you get started, we’ve selected a few angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esvit / ng-table / test / specs / selectFilterDs.spec.ts View on Github external
interface ColumnScope extends IScope {
        $column: { data?: SelectData };
        $selectData?: SelectOption[];
    }

    interface TableScope extends IScope {
        $new(): ColumnScope;
    }

    let $scope: ColumnScope,
        elem: string,
        $compile: ICompileService;

    beforeAll(() => expect(ngTableBrowserModule).toBeDefined());
    beforeEach(ng1.mock.module('ngTable-browser'));

    beforeEach(inject(($rootScope: TableScope, _$compile_: ICompileService) => {
        $scope = $rootScope.$new();
        $compile = _$compile_;
        elem = '<select></select>';
    }));

    describe('array datasource', () =&gt; {

        it('should add array to current scope', () =&gt; {
            // given
            let data = [{ id: 1, title: 'A' }];
            $scope.$column = {
                data: data
            };
            // when
github flow-typed / flow-typed / definitions / npm / angular_v1.5.x / flow_v0.47.x-v0.103.x / test_utility_functions_v1.5.x.js View on Github external
function testExtend() {
  // extends object type
  (angular.extend({ a: 1 }, { b: 2 }): { a: number, b: number });
  (angular.extend({ a: 1 }, { b: 2 }, { c: "str", d: 123 }): {
    a: number,
    b: number,
    c: string,
    d: number
  });
}
github spring-projects / spring-flo / tests / resources / metamodel-service.js View on Github external
return $http.get('/parse', { params: {'text': definitionText}}).success(function(data) {
				if (angular.isFunction(setErrorFn)) {
					setErrorFn(null);
				}
				if (typeof data === 'string') {
					data = angular.fromJson(data);
				}
				// TODO handle error case, clear the graph
				$log.info('parse responded with data:\''+JSON.stringify(data)+'\'');
				if (angular.isFunction(updateGraphFn)) {
					updateGraphFn(data);
				}
			}).error(function(data, status, headers, config, statusText) { // jshint ignore:line
				if (typeof data === 'string') {
github spring-projects / spring-flo / tests / resources / metamodel-service.js View on Github external
return $http.get('/parse', { params: {'text': definitionText}}).success(function(data) {
				if (angular.isFunction(setErrorFn)) {
					setErrorFn(null);
				}
				if (typeof data === 'string') {
					data = angular.fromJson(data);
				}
				// TODO handle error case, clear the graph
				$log.info('parse responded with data:\''+JSON.stringify(data)+'\'');
				if (angular.isFunction(updateGraphFn)) {
					updateGraphFn(data);
				}
			}).error(function(data, status, headers, config, statusText) { // jshint ignore:line
				if (typeof data === 'string') {
github i18next / ng-i18next / src / provider.spec.ts View on Github external
beforeEach(() => {

			angular.mock.module('jm.i18next', ($i18nextProvider: ng.IServiceProvider) => {
				i18next.init(i18nextOptions, (err, t) => {
					// console.log('resources loaded');
				});

				i18next.on('initialized', (options) => {
					// console.log('i18next initialized');
					i18nextOptions = options;
				});
			});

			inject((
				_$i18next_: Ii18nTranslateService,
				_$timeout_: ng.ITimeoutService,
				_$rootScope_: ng.IRootScopeService) => {
				$i18next = _$i18next_;
				$timeout = _$timeout_;
github ngOfficeUIFabric / ng-officeuifabric / src / components / persona / personaDirective.spec.ts View on Github external
it('should have CSS for size', () =&gt; {
        let personas: angular.IAugmentedJQuery[] = [
          angular.element(''),
          angular.element(''),
          angular.element(''),
          angular.element(''),
          angular.element('')
        ];

        let expectedClass: string[] = ['ms-Persona--tiny', 'ms-Persona--xs', 'ms-Persona--sm', 'ms-Persona--lg', 'ms-Persona--xl'];

        for (let i: number = 0; i &lt; personas.length; i++) {
          _compile(personas[i])(scope);
        }
        scope.$digest();

        let persona: JQuery;
        // let innerDiv: JQuery;

        for (let i: number = 0; i &lt; personas.length; i++) {
          persona = jQuery(personas[i]);
          // innerDiv = persona.find('div.ms-Persona');
github Teradata / kylo / ui / ui-app / src / main / resources / static / js / feed-mgr / services / fattable / FattableService.ts View on Github external
self.table.W = columnOffset[columnOffset.length - 1];
            self.table.setup();

            // console.log('displaying cells', scrolledCellX, scrolledCellY);
            self.table.scroll.setScrollXY(x, y); //table.setup() scrolls to 0,0, here we scroll back to were we were while resizing column
        }

        const eventId = "resize.fattable." + settings.tableContainerId;
        angular.element($window).unbind(eventId);
        const debounced = _.debounce(self.setupTable, settings.setupRefreshDebounce);
        angular.element($window).on(eventId, function () {

            debounced(settings);
        });

        angular.element(selector).on('$destroy', function () {

            angular.element($window).unbind(eventId);
        });
    }
github ovh / manager / packages / components / ng-ovh-sso-auth / src / factory.js View on Github external
return ssoAuthentication.getSsoAuthPendingPromise().then(() => {
          config.headers = angular.extend(
            angular.copy(ssoAuthentication.getHeaders()),
            config.headers,
          );

          // For no prefix if begins with http(s)://
          if (urlPrefix && !/^http(?:s)?:\/\//.test(config.url)) {
            config.url = urlPrefix + config.url;
          }

          if (config.timeout) {
            const deferredObjTimeout = $q.defer();

            // Can be cancelled by user
            config.timeout.then(() => {
              deferredObjTimeout.resolve();
            });
github OpenSOC / opensoc-ui / src / kibana / components / courier / saved_object / saved_object.js View on Github external
self.save = function () {
        var body = {};

        _.forOwn(mapping, function (fieldMapping, fieldName) {
          if (self[fieldName] != null) {
            body[fieldName] = (fieldMapping._serialize)
              ? fieldMapping._serialize(self[fieldName])
              : self[fieldName];
          }
        });

        if (self.searchSource) {
          body.kibanaSavedObjectMeta = {
            searchSourceJSON: angular.toJson(_.omit(self.searchSource.toJSON(), ['sort', 'size']))
          };
        }


        // Slugify the object id
        self.id = slugifyId(self.id);

        // ensure that the docSource has the current self.id
        docSource.id(self.id);

        // index the document
        return self.saveSource(body);
      };
github ORCID / ORCID-Source / orcid-web / src / main / webapp / static / javascript / ng1Orcid / app / controllers / OtherNamesCtrl.ts View on Github external
$scope.setOtherNamesForm = function(){
                $scope.otherNamesForm.visibility = null;
                $.ajax({
                    url: getBaseUri() + '/my-orcid/otherNamesForms.json',
                    type: 'POST',
                    data:  angular.toJson($scope.otherNamesForm),
                    contentType: 'application/json;charset=UTF-8',
                    dataType: 'json',
                    success: function(data) {                
                        $scope.otherNamesForm = data;
                        if(data.errors.length == 0){
                            $scope.close();                 
                        }
                        $.colorbox.close(); 
                        $scope.$apply();                
                    }
                }).fail(function() {
                    // something bad is happening!
                    console.log("OtherNames.serverValidate() error");
                });
            };